How do I create a macro to open a file in Access?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I can get Access to open a program like Microsoft Word, but I can't get it to
open a specific file like help.doc. Is this possible
 
Curahee,

You can use a RunApp action in your Access macro. The Command Line
argumet will be something like this...
"C:\Program Files\...\Winword.exe" "C:\YourFolder\help.doc"
 
That works. Thanks.

Steve Schapel said:
Curahee,

You can use a RunApp action in your Access macro. The Command Line
argumet will be something like this...
"C:\Program Files\...\Winword.exe" "C:\YourFolder\help.doc"
 
Thanks. Is there a way to have it go to a specific mail merge record in the
Word document after the document is opened using this process? The record to
go to in Word will be the same record that is selected on the Access form
when the macro to open Word is selected. Thanks.
 
Steve,

I guess you could use a query for the Word merge document's Data Source.
And then you could put a criteria in the query, which references the
current record in the form, using syntax such as...
[Forms]![NameOfYourForm]![YourID_Field]
 
I don't quite understand. The Word mail merge Data Source is an Access
Table. There are about 100 unique records in the Access Table Data Source
that create the 100 separate Word mail merge documents. I have a macro that
opens the Word document from Access (using RunApp) and when the Word document
opens, it displays the first record from the Access Table as the first mail
merge document. The macro is executed from a form that displays information
about a specific record selected from a Combo box. When the macro is
executed, I want the mail merge to display the document that aligns with the
specific record displayed in the Combo box. Make sense? Is this doable?
Thanks.
Steve Krieger


Steve Schapel said:
Steve,

I guess you could use a query for the Word merge document's Data Source.
And then you could put a criteria in the query, which references the
current record in the form, using syntax such as...
[Forms]![NameOfYourForm]![YourID_Field]

--
Steve Schapel, Microsoft Access MVP


Steve said:
Thanks. Is there a way to have it go to a specific mail merge record in the
Word document after the document is opened using this process? The record to
go to in Word will be the same record that is selected on the Access form
when the macro to open Word is selected. Thanks.
 
Steve,

I think I already understood your situation, so I'll continue to work on
that assumption :-).

My suggestion is to change the Word merge document's Date Source from
the table that it is at the moment, to a query that only returns the
record associated with the current record on your Access form. Is there
a problem with this basic concept?
 
My goal was to have 1 Word mail merge document rather than 100. I' see if I
can work around it. Thanks.
 
Steve,

Well, you wouldn't need 100 Word documents! Can I clarify... do you
want the word document to open showing the current record from the form,
*and* still be able to scroll through the merge for all the other
records? If so, there is an easy way to do this. But I inderstood that
you only wanted the Word merge doc to show the current record from the
form. Either way, this would apply *whatever* the current record on the
form might be, so obviously you only need one Word document. Apologies
that I don't seem to be quite connecting with where you're at with this,
but whatever you want will be easy.
 
Yes, what I want to do is the first thing you state below. Open the Word
document so that it goes directly to the current mail merge record from the
form and still be able to scroll through the merge for all other records.
This should result in one mail merge document, including all records from the
Access data source, and showing the Word merge record that is the same as the
current record on the Access form.
Sorry I wasn't clear. I'm glad there's an easy way to do this, but you'll
have to explain it to me. Thanks for your help.
 
Steve,

Ok, thanks for the further explanation.

This is what I had in mind... In the query that you use as the Data
Source for the merge document, put a calculated field the equivalent of
this...
[YourIDField]=[Forms]![NameOfYourForm]![YourIDField]
You would type this into the Field row of a blank column in the query
design grid.
And then Sort on this calculated field in the query. This should result
in the form's current record being the first record returned by the
query, and therefore the record displayed when the Word merge document
is first opened.
 
Back
Top