S
Stefania Scott
I wrote the following code from access to atomatically open a word
document:
Set oWord = New Word.Application
oWord.Visible = False
Set oWordDoc = oWord.Documents.Open(strWS_Path)
'oWord.Documents.Add (strWS_Path)
oWordDoc.MailMerge.Destination = wdSendToNewDocument
oWordDoc.MailMerge.Execute
oWordDoc.Application.ActiveDocument.Fields.Update
oWordDoc.Application.Options.PrintBackground = False
oWordDoc.Application.ActiveDocument.PrintOut
oWordDoc.Close Word.wdDoNotSaveChanges
oWord.Quit Savechanges:=wdDoNotSaveChanges
Set oWord = Nothing
Set oWordDoc = Nothing
I never have any sort of error when I run this code from my local
copy. The same code instead run in another computer (of course the
one the metter) by accessing the same word document gives me the
following error:
"Word could not merge the main document with the data source because
the data records were empty or no data records matched your query
options."
which error does not occur all the time.
After the error occurred if I open the word document directly it seems
there is no problem, the document looks correct and the data source is
not empty.
In this particular computer I had also to put a SQLSecurityCheck in
the regestry
otherwise when opening a document with mail merge was always asking
the question if I wanted to run the SQL statment. I did not have to
put this fix in my computer.
Do you know if this problems are related?
Please help! I am desperate.
Thank you so much in advance.
Stefania
document:
Set oWord = New Word.Application
oWord.Visible = False
Set oWordDoc = oWord.Documents.Open(strWS_Path)
'oWord.Documents.Add (strWS_Path)
oWordDoc.MailMerge.Destination = wdSendToNewDocument
oWordDoc.MailMerge.Execute
oWordDoc.Application.ActiveDocument.Fields.Update
oWordDoc.Application.Options.PrintBackground = False
oWordDoc.Application.ActiveDocument.PrintOut
oWordDoc.Close Word.wdDoNotSaveChanges
oWord.Quit Savechanges:=wdDoNotSaveChanges
Set oWord = Nothing
Set oWordDoc = Nothing
I never have any sort of error when I run this code from my local
copy. The same code instead run in another computer (of course the
one the metter) by accessing the same word document gives me the
following error:
"Word could not merge the main document with the data source because
the data records were empty or no data records matched your query
options."
which error does not occur all the time.
After the error occurred if I open the word document directly it seems
there is no problem, the document looks correct and the data source is
not empty.
In this particular computer I had also to put a SQLSecurityCheck in
the regestry
otherwise when opening a document with mail merge was always asking
the question if I wanted to run the SQL statment. I did not have to
put this fix in my computer.
Do you know if this problems are related?
Please help! I am desperate.
Thank you so much in advance.
Stefania