1. Li Mei Weng
  2. PowerBuilder
  3. Thursday, 28 September 2017

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.

René Ullrich Accepted Answer Pending Moderation
0
Votes
Undo

Is Excel 32 Bit oder 64 Bit installed? From PB 32 Bit you can only access Excel 32 Bit!

Comment
PB and excel are 32-bit.

  1. Li Mei Weng
  2. Friday, 29 September 2017
There are no comments made yet.
  1. Thursday, 28 September 2017
  2. PowerBuilder
  3. # 1
René Ullrich Accepted Answer Pending Moderation
0
Votes
Undo

Your code works for me with PB 2017 and Excel 2016.

Comment
The code has been updated to the Question area...

  1. Li Mei Weng
  2. Friday, 29 September 2017
Works for me also with your new code. Was your Open call successfull? Is the specified file in ls_path ok?



I think, 1 is not a valid value for FileFormat parameter of SaveAs function in Excel. (see https://msdn.microsoft.com/library/ff198017.aspx)

  1. René Ullrich
  2. Friday, 29 September 2017
There are no comments made yet.
  1. Thursday, 28 September 2017
  2. PowerBuilder
  3. # 2
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.