This is a sample of a command button put on a Access form.
It launches Microsoft Word (any Version) then Opens a document and also can run a Macro. The macro is a Word macro you create in word just like any other macro. For Example the macro could Print the Mail Merged document and then Quit Word bringing you back to Access.
---------------------------------------------------
Private Sub Command19_Click()
On Error GoTo Err_Command19_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 = "F:\Somefolder\MyDoc.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:\Microsoft Office97\Office\WinWord.exe" & " " & DocName & MacroName, vbNormalFocus)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.