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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RUNNING A WORD MACRO AFTER OPENING A WORD FILE FROM ACCESS

Status
Not open for further replies.

oggsta

Technical User
Jun 22, 2002
41
GB
I have a macro named peter

Which is located in teh following file.
\company\PLANNING\Informationplanning\Templates\Vodafone\Database\PRE-AP-Parish1.doc

The code below opens a word document however i would also like it to run the macro named Peter.

What is the correct syntax for the code that i need to include to be able to run the macro.

Any help much appreciated.



Private Sub Command596_Click()

Dim stDocName As String

stDocName = "refresh"
DoCmd.RunMacro stDocName

On Error GoTo Err_Command596_Click
' Button launches Word and opens a specified document
' And runs an optional macro. the macro could print out the word doc and quit

Dim retval As Variant
Dim DocName, MacroName As String
' Drive and Full path to name and location of Word document
DocName = "\\Cpsglobal01\company\PLANNING\Informationplanning\Templates\Vodafone\Database\PRE-AP-Parish1.doc"

'Optional Macro Name. Note Word Macro name cannot have any spaces in it.
'MacroName = "/M" & "MacroName"

'Note full path to Word including Drive and folder
retval = Shell("C:\Program Files\Microsoft Office\Office\winword.exe" & " " & DocName & MacroName, vbNormalFocus)

Exit_Command596_Click:
Exit Sub

Err_Command596_Click:
MsgBox Err.Description
Resume Exit_Command596_Click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top