- Li Mei Weng
- PowerBuilder
- Thursday, 28 September 2017 08:55 AM UTC
Hi,
I use code and run, I can get what I want (Powerbuilder 10.5 and MS-Excel 2003)
oleobject myoleobject, lole_Sheet
myoleobject = CREATE OLEObject
myoleobject.ConnectToNewObject("Excel.Application")
myoleobject.Application.StandardFont = "Arial"
myoleobject.Application.StandardFontSize = "9"
myoleobject.Application.DisplayAlerts = False
myoleobject.Workbooks.Open(ls_path)
lole_Sheet = myoleobject.ActiveSheet
lole_Sheet.Cells(1,1).Value = 'Column name'
lole_Sheet.Cells(2,2).Value = 'Sql Column Name'
lole_Sheet.Cells(3,3).Value = 'nvarchar(20)'
myoleobject.Activeworkbook.SaveAS(ls_path , 1)
myoleobject.Workbooks.close()
myoleobject.quit()
And, when I use Powerbuilder 10.5 and MS-Excel 2016, I got Error at "myoleobject.Workbooks.Open(ls_path)"
Now, I want to use Powerbuilder 2017 and MS-Excel 2016...
How can I modify it?
===========================================================================
I tried "myoleobject.ConnectToNewObject("Excel.Application")" using Powerbuilder 2017 and MS-Excel 2016, the value return -2..
===========================================================================
I was reinstall the MS-office 2016 (x86), and check PB 2017 is 32-bit.
"myoleobject.ConnectToNewObject("Excel.Application")" return 0
The code runs to "myoleobject.Workbooks.Open(ls_pah)" and the code "lole_Sheet = myoleobject.ActiveSheet" will not be executed.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.