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

Mail merge code cant find document ( calling it .doc1)

Status
Not open for further replies.

SpectacledBear

Programmer
Mar 1, 2005
58
0
0
GB
Hi there, I have a mail merge button which has the following code on its on click event:

Dim retval As Variant
Dim DocName As String
' Drive and Full path to name and location of Word document
DocName = "E:\Word\MailMerge.doc"

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

when I run it, word opens and then i see a message box saying could not find the document (E:\Word\MailMerge.doc1). Why is it putting a 1 after the doc? is this why it cant find it?
 
Hi
Do you need another couple of "?
retval = Shell("C:\Program Files\Microsoft Office\Office10\WinWord.exe" & "" & DocName & "" & vbNormalFocus)
 
HI there, I've done as you said, but it hasn't done the trick. Any other suggestions? thanks!
 
retval = Shell("C:\Program Files\Microsoft Office\Office10\WinWord.exe" & "" & DocName, vbNormalFocus)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
retval = Shell("C:\Program Files\Microsoft Office\Office10\WinWord.exe" & "" & DocName, vbNormalFocus)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi, tried all suggestions, still says error cannot find document.
 
Oops, sorry for the typo:
retval = Shell("C:\Program Files\Microsoft Office\Office10\WinWord.exe " & DocName, vbNormalFocus)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi, the code now reads:

Dim retval As Variant
Dim DocName As String
document
DocName = "E:\Word\MailMerge.doc"

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

This opens the mail merge document fine.

However, on opening the mail merge, the database is launched, and the user has to log in before the mail merge displays the records in the query (the db is already open, mail merge doc is launcehed from a form..)

why is it doing this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top