1. Raymond Longoria
  2. PowerBuilder
  3. Tuesday, 20 April 2021 02:13 AM UTC

I migrated an application from 8.0 to 2019 R3. I found a windows script command that is supposed to open an Excel file but it is not working. Does this need a syntax fix or is there a better way to open the file? The following is the code:

 

wsh = CREATE OleObject
result = wsh.ConnectToNewObject( "WScript.Shell" )

result = wsh.Run("C:\filepath\report.xlsx" , 3, 0)

John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 20 April 2021 04:33 AM UTC
  2. PowerBuilder
  3. # 1

Hi, Raymond -

That night work, I don't know. However, a lot has changed since the late 1990's. The typical way to open Excel, Word, Outlook, etc. is to use OLE. I suggest you do a search in Q&A for "ConnectToNewObject" - I just did that and got 18 hits, several of which are related to Excel and some contain code snippets. You might also look through the online documentation for "Excel", check the PB Tutorials and the code samples in CodeXchange.

Regards, John

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 20 April 2021 04:50 AM UTC
  2. PowerBuilder
  3. # 2

Hi Raymond,

I use the same logic and it works for me.

What exactly doesn't work? Exception? Returncode of ConnectToNewObject? ReturnCode of Run?

The code may only work if Windows know how to handle file with XLSX extension. May you open such files in your Windows Explorer?

Regards,

René

 

Comment
  1. Raymond Longoria
  2. Thursday, 29 April 2021 17:19 PM UTC
I ended up using ShellExecuteA to open the Excel file.

Thanks to everyone for their input.
  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.