Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: Access Other topics FAQ

Access Howto:

Shell to Word, Open a Doc and run a Macro by DougP
Posted: 23 May 00

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)

    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command19_Click
End Sub
Here is an FAQ on Creating a WORD Doc to mail merge with Access database query.

Back to Microsoft: Access Other topics FAQ Index
Back to Microsoft: Access Other topics Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close