A
amak
Hello everyone,
I am have inherited some code that does a mail merge of client forms in
powerbuiler. The underlying problem is not with powerbuilder, but in
how the ole object is working. I've opened a word application thru
code and have populated the datasource.
// active external application
la_OLEReturn = ole_1.Activate(Offsite!)
// open datacource
ole_1.Object.Application.ActiveDocument.MailMerge.OpenDataSource("c:\mail_merge\datasource_"
+ string(al_header_id) + ".rtf",
0,FALSE,FALSE,FALSE,FALSE,"","",FALSE,"","","","","")
// hide the merge codes, so the actual value can be seen
ole_1.object.Application.ActiveDocument.MailMerge.ViewMailMergeFieldCodes
= FALSE
// execute the merge.
ole_1.object.Application.ActiveDocument.MailMerge.Execute
// set print background to false, otherwise MS Word complains that
'Word is still Printing'
ole_1.Object.Application.Options.PrintBackground = False
// Print the merged documents
ole_1.object.Application.ActiveDocument.PrintOut(-1)
// close the current document
ole_1.object.Application.ActiveDocument.Close(0,1)
Everything works and prints fine, just not the way we want it to. When
the Active(Offsite!) executes, it opens an instance of word and then
populates it with the datastore when that is fired. When the Execute
fires, that opens up a new instance of word with merged data. Then it
prints and closes as code is fired. We do not want to have new
instances of word opening and closing up like a slide show when there
are multiple forms being printed. Is there a way to have the mail
merge stay within the first opened word instance or even just a second
one?
Thank you for the help.
I am have inherited some code that does a mail merge of client forms in
powerbuiler. The underlying problem is not with powerbuilder, but in
how the ole object is working. I've opened a word application thru
code and have populated the datasource.
// active external application
la_OLEReturn = ole_1.Activate(Offsite!)
// open datacource
ole_1.Object.Application.ActiveDocument.MailMerge.OpenDataSource("c:\mail_merge\datasource_"
+ string(al_header_id) + ".rtf",
0,FALSE,FALSE,FALSE,FALSE,"","",FALSE,"","","","","")
// hide the merge codes, so the actual value can be seen
ole_1.object.Application.ActiveDocument.MailMerge.ViewMailMergeFieldCodes
= FALSE
// execute the merge.
ole_1.object.Application.ActiveDocument.MailMerge.Execute
// set print background to false, otherwise MS Word complains that
'Word is still Printing'
ole_1.Object.Application.Options.PrintBackground = False
// Print the merged documents
ole_1.object.Application.ActiveDocument.PrintOut(-1)
// close the current document
ole_1.object.Application.ActiveDocument.Close(0,1)
Everything works and prints fine, just not the way we want it to. When
the Active(Offsite!) executes, it opens an instance of word and then
populates it with the datastore when that is fired. When the Execute
fires, that opens up a new instance of word with merged data. Then it
prints and closes as code is fired. We do not want to have new
instances of word opening and closing up like a slide show when there
are multiple forms being printed. Is there a way to have the mail
merge stay within the first opened word instance or even just a second
one?
Thank you for the help.