Cmd Button to word file

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

Guest

Can someone help me edit this code so it opens the MS Word file at the path
listed below?

P:\Rockingham\MergeFiles\Returned Paperwork Reminder Email.doc


Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Exit_Command10_Click:
Exit Sub

Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click

End Sub

Thank you very much
 
call docmd.runapp("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE
P:\Rockingham\MergeFiles\Returned Paperwork Reminder Email.doc")
 
Ooops.. guess that only works in a macro.

Lance said:
call docmd.runapp("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE
P:\Rockingham\MergeFiles\Returned Paperwork Reminder Email.doc")
 
have to use the shell function..

Call Shell("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE
P:\Rockingham\MergeFiles\Returned Paperwork Reminder Email.doc")
 
Can someone help me edit this code so it opens the MS Word file at the path
listed below?

P:\Rockingham\MergeFiles\Returned Paperwork Reminder Email.doc

Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Exit_Command10_Click:
Exit Sub

Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click

End Sub

Thank you very much

Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

Application.FollowHyperink "P:\Rockingham\MergeFiles\Returned
Paperwork Reminder Email.doc"

Exit_Command10_Click:
Exit Sub

Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click

End Sub
 
Actually, that won't work due to the embedded spaces in the path.

You need to put quotes around the path to winword.exe, and around the path
to the document:

Call Shell("""C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE""
""P:\Rockingham\MergeFiles\Returned Paperwork Reminder Email.doc""")

Since that's going to suffer from word-wrap in the reply, symbolically it's

Call Shell("""C:\...\winword.exe"" ""P:\...\...email.doc""")

That's three double quotes at the beginning and end, and two pairs of double
quotes, separated by a space, in the middle.

An alternative would be:

Application.FollowHyperlink "P:\Rockingham\MergeFiles\Returned Paperwork
Reminder Email.doc"
 
Macro - Runapp
In the runapp command line copy then paste this as it is.

WinWord.EXE "P:\Rockingham\MergeFiles\Returned Paperwork Reminder Email.doc"

Cheers!
 
Sorry forgot to add. To set up the button.

Creat the command button using the wizard.
Select Miscellaneous
Select RunMacro
Click next button
Select the Macro you created to perfrom the runapp
and click finish.

Your done. Or in the event procedures select onCLick and select the macro
there.
 
Or, simpler (since it doesn't require you to know the name of the
executable),

Application.FollowHyperlink "P:\Rockingham\MergeFiles\Returned Paperwork
Reminder Email.doc"
 
Back
Top