1. Li Mei Weng
  2. PowerBuilder
  3. 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.

René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 28 September 2017 13:01 PM UTC
  2. PowerBuilder
  3. # 1

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

Comment
  1. Li Mei Weng
  2. Friday, 29 September 2017 03:07 AM UTC
PB and excel are 32-bit.

  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 28 September 2017 10:18 AM UTC
  2. PowerBuilder
  3. # 2

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

Comment
  1. Li Mei Weng
  2. Friday, 29 September 2017 03:10 AM UTC
The code has been updated to the Question area...

  1. Helpful
  1. René Ullrich
  2. Friday, 29 September 2017 06:00 AM UTC
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. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.