Cmd Button to word file

J

Jason

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
 
L

Lance

call docmd.runapp("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE
P:\Rockingham\MergeFiles\Returned Paperwork Reminder Email.doc")
 
L

Lance

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")
 
L

Lance

have to use the shell function..

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

fredg

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
 
D

Douglas J. Steele

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"
 
K

K

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!
 
K

K

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.
 
D

Douglas J. Steele

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top