>Hi Tamar,
>
>Thanks for the assistance. After I use Automation to execute a merge, the datasource is the topmost active document. If I close it, then I get the print preview. If I close() it in my routine I get an OLE exception from Word. Is there a way I can hide it, or some other way of closing it?
>
I'm a little confused by what you say you're seeing. When you've finished the merge, there should be three open documents: the main document, the data source and the merged result.
You can close both the main document and the data source. The easiest way to do this is to make sure you have a object reference to each before executing the merge. Then you can use those object references to close those documents.
My experience is that the merged result is the active document after a merge, but I suppose that could vary with the Word version. Unfortunately, the MailMerge.Execute method doesn't give you back an object reference to the result, but if it's the active document, it's easy to grab one.
Unless you choose to execute a Preview (as the sample code in AutoFox does), you shouldn't be seeing a print preview at all.
What's the goal here? Are you trying to print the merged result? Save it? something else?
Tamar
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement