Click here to Skip to main content
15,887,376 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
while saving OLEObject from the SQL DB to a physical file(.doc) it opens the MS Word and displays the error
“word could not merge the main document with the data source because the data records were empty”

Used the following code:
OLE1.object.SaveAs strDir & "\" & strFileName & ".doc"

Need to save it silently without opening anything


Please Help
Posted

VBARC wrote:
word could not merge the main document with the data source because the data records were empty

Sounds like it's a mailmerge document? Is there a database hooked up to the Word-document?

As it stands, it looks like the Word-file is saved correctly, and that the MailMerge function starts acting up when you open the document. Does it work correctly if you save an "empty" Word-document?
 
Share this answer
 
When opening the Word document itself it throws that error.i think its looking for the datasource and querying what the client is having already.

So when assing that in to ole itself,throws the error.

Need save it in to physical file without popping up the error.
 
Share this answer
 
You could put your SaveAs statement in a Try Catch block, then just don't do anything if an error is caught. The only down side is that if ANY error prevents the file from saving it will be skipped as well, so you may want to add something to keep track of the error. Wait...you're using VB6...I'm not sure it's a Try Catch block then...it might be something like On Error GoTO...you'll have to google[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900