Hi,
I encounter following problem when execute excel macro in Powerbuilder.
Environment:
- Power Builder 2017 R3 on Windows 10
- Excel version is Excel for Office 365
Problem script:
try
lo_myoleobject.application.run("ThisWorkbook.change_data_format")
catch (oleruntimeerror er)
lo_myoleobject.disconnectobject()
destroy lo_myoleobject
return -1
end try
When execute above scripts, it return "Error calling external object function run at line 112 in function...."
The problem line is "lo_myoleobject.application.run("ThisWorkbook.change_data_format")"
However, there is no problem if use Excel 2003.
Please let me know what could be the issue?. Thanks.
Regards
Thanks for your clear explanation. It works after I changed to use ConnectToNewObject method as following. The macro in 2003 Excel files (,xls) can be processed too.
li_result = lo_myoleobject.ConnectToNewObject( "excel.application" )
try
lo_myoleobject.workbooks.Open("C:\a.xls")
lo_myoleobject.application.run("ThisWorkbook.change_data_format")
catch (oleruntimeerror er)
lo_myoleobject.disconnectobject()
destroy lo_myoleobject
return -1
end try
Many thanks for your help.
Regards