1
votes

We are using MS Office 2010 with PowerBuilder 10.5. While using mail merge functionality from PowerBuilder application. It got application terminated. But in the later version works as usual..

I checked the Word document in the older version.. When opening that word document ( mail merge used in that) the data file (recipient file of address_data.xls) also will be opening. But in the Newer version it didn't open. is there any option to open the excel file, while opening the document?

When opening the mail merged word document. It opens with Excel file in MS Office 97. But this is not working in MS Office 2010. I need to open that document in MS Office 2010 - Word 2010 so this should open that excel file too. How can I do that?

1
Hi, can you please clarify? What were you using that worked? What did you change? Please post the PowerBuilder code you are using to control Word.Hugh Brackett
ole_1.object.application.ActiveDocument.MailMerge.Execute() This is the line - here the application terminated.Ambat bhath
When opening the mail merged word document. It opens with Excel file in MS Office 97. But this is not working in MS Office 2010. I need to open that document in MS Office 2010 - Word 2010 so this should open that excel file too. How can I do that?Ambat bhath
What happens when you open the document from Word (not using PB)? If the mail merge won't work in Word it won't work in PB. You might have to make a new Word document for Office 2010.Hugh Brackett
While opening the work document, it asked conversion from the existing version. i said yes then opens word document with the excel document. This is the desired behaviour but the code ole_1.Object.Application.ActiveDocument.MailMerge.Execute() this part fails and returns the powerbuilder application error(R0035)Ambat bhath

1 Answers

0
votes

Try opening the Word document like this:

iole_word = CREATE OLEObject
li_result  = iole_word.ConnectToNewObject("word.application")
// error checking code omitted

// args: FileName, [ConfirmConversions], [ReadOnly], [AddToRecentFiles]
ole_1 = iole_word.Documents.Open(is_infile,FALSE,FALSE,FALSE)

I didn't show it here, but you should put the whole thing in a try-catch block and catch oleruntimeerror. If Word can't open the file, it throws oleruntimeerror. I presume that's also what it's throwing when the MailMerge fails.

If that doesn't work I'd make a new mailmerge document for Office 2010. If you need to support both versions you could check the Word version via the OLE interface to determine which document to use.