Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a Word Userform from Access with Automation

Status
Not open for further replies.

tgharris

Technical User
Jan 25, 2000
24
US
I have a Userform macro attached to a Word document I call from Access. I want to activate this userform from Access code so I do not have to run the macro every time I open the document for mail merge or revision. Could anyone suggest some code for doing this?<br>
<p>Tony Harris<br><a href=mailto:tgharris@techie.com>tgharris@techie.com</a><br><a href= > </a><br>
 
First of all copy and paste this thread and print it out.<br>
<br>
Go in Access<br>
Add a command button to your form. <br>
In &quot;Categories&quot; list choose &quot;Application&quot;<br>
In &quot;Actions&quot; list chose &quot;Run Application&quot; DO NOT choose &quot;Run MS Word&quot; it won't work correctly in this instance.<br>
Find Words command line and finish it out.<br>
Right click on the button and open the code view.<br>
<br>
Here is an example of mine <br>
Also if you don't know where Word is, look at mine it will help you find it.<br>
There are more lines it made, I just go the basics we need.<br>
<br>
Dim stAppName As String<br>
<br>
stAppName = &quot;E:\Microsoft Office2000\Office\WINWORD.EXE&quot;<br>
Call Shell(stAppName, 1)<br>
<br>
On this line <br>
stAppName = &quot;E:\Microsoft Office2000\Office\WINWORD.EXE&quot;<br>
add the following like so to the end of the line. Don't use those continuation things it needs to be on one long line.<br>
stAppName = &quot;E:\Microsoft Office2000\Office\WINWORD.EXE&quot; & &quot; &quot; & &quot;C:\Test.doc&quot; & &quot; &quot; & &quot;/Mmacroname&quot;<br>
OK notice we have: Application name and a blank space, Document name and a blank space, then /M (which runs a macro) and the macro name with no space between /M and macro name<br>
NOW the macro name can NOT have any spaces it either. If yours does re-name it.<br>
<br>
See any program when launched can be passed the Name of it's document and a option such as Run Macro.<br>
You probably guessed that if you created a short cut on your desktop that it is fair game and YES you can edit it do the same thing.<br>
<br>
So to load Access and be on the form to run your word thing create a short cut on your desktop and follow the same procedure.<br>
BUT in Access use &quot;/X Macroname&quot; <br>
AND IN Access there has to be a space between /X and the macro name. In Word its all jammed together with no space &quot;/Mmacroname&quot; <br>
Also remember after the document name there must be a space before the macro command.<br>
<br>
OK and soon you will find all sorts of uses for the &quot;One Click Icons&quot; as I call them.<br>
I got a whole desk top full of them….<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top