View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Don
 
Posts: n/a
Default .ActiveDocument.mailmerge Syntax sometimes not working

The main document is linking correctly to the text file that I have it set
to. I have looked at the main document(mailmerge document) and the values
are being pulled from the text file. I just get an error message when trying
to execute it into a new document.

"Peter Jamieson" wrote:

An attempt to set .Destination will fail if there is no data source. Since
there is no OpenDataSource method call in the code you have posted, my guess
is that you have attached the word document to a data source, then closed
it. That's fine, unless Word cannot re-attach the document to the source
when it re-opens the document, and that could happen for various reasons,
e.g. the data source is not where Word expects to find it, or some users are
using a different Word version or Service Pack from others. Ther are a
couple of things you could try to find out what is gong on:
a. add error trapping to your Access code, if you haven't already
b. ask 1 user whose system works and 1 user whose system doesn't to open
the datasource manually, and see what happens.

Peter Jamieson

"Don" wrote in message
...
Hello, I'm using this code below from with Access to open a Word document.
It works fine on my machine but I have a user that gets an error when
trying
to run the mailmerge.execute line. Any thought why?

Dim objApp As Object
Dim strDocName As String
Dim strDocNameB As String
'strDocName = rs!ClosingDir & "\MasterTest.doc"
strDocName = rs!ClosingDir & "\" & rs!ClosingDoc
Set objApp = CreateObject("Word.application")
With objApp
.Visible = True
.Documents.Open strDocName
strDocNameB = objApp.ActiveDocument.Name
***Lines Below sometimes don't work on other machines.
.ActiveDocument.mailmerge.Destination = 0 'wdSendToNewDocument
.ActiveDocument.mailmerge.Execute
.Documents(strDocNameB).Close 0
End With