1. David Vasconcelos
  2. PowerBuilder
  3. Friday, 21 April 2017 12:56 PM UTC

If I open an Excel file through PB 12.5 classic using the ShellExcuteW API it opens the file correctly.

I type or change something in the file and close it without saving.  Excel does not detect a change and ask if I want to save.

If I open the same file using Excel directly and make a change and try to close, it does detect the change and ask if I want to save.

Is this normal behavior for ShellExecuteW or is there something else I need to do.

Thanks

Dave V.

Excel is Office 2016 and running on Windows 7 64 bit.

David Vasconcelos Accepted Answer Pending Moderation
  1. Wednesday, 10 May 2017 14:03 PM UTC
  2. PowerBuilder
  3. # 1

I eventually got it to work, I ended up creating a function and put the API call in it.  I then just called the function and for some reason it worked.  I can only guess that it may have been some sort of timing issue between closing the OLE and calling Exel to open the same file.

Dave V.

Comment
There are no comments made yet.
Chris Pollach Accepted Answer Pending Moderation
  1. Friday, 21 April 2017 13:54 PM UTC
  2. PowerBuilder
  3. # 2

Hi Dave;

   Can you post your PowerScript logic around the ShellExecuteW API command that you are using?

Regards ... Chris

Appeon: Director, Developer Relations

Comment
  1. David Vasconcelos
  2. Monday, 24 April 2017 18:43 PM UTC
It's got something to do with the way I am using OLE...script attached.  Maybe not closing correctly...



Basically I am opening a spreadsheet, running a macro then deleting the macro and savas as... hope this is almost clear as mud..



 



IF FileExists(ls_excl_sheet) and FileExists(ls_file) then

 IF ole_object.ConnectToNewObject("excel.application") = 0 THEN

   ole_object.Application.DisplayAlerts = "False"

   ole_object.workbooks.Open(ls_excl_sheet) //Open the excel file

 Else

   MessageBox('OLE Error','Unable to start an OLE server process!',Exclamation!)

 END IF

 

 ole_object.Application.Run("GetFileData", ls_file)

 ole_object.Application.workbooks(1).RefreshAll

     ole_object.Application.workbooks(1).Connections("sched_view").Delete

     ole_object.ActiveWorkbook.SaveAs(ls_existing_file,51)  //xlOpenXMLWorkbook

 ole_object.Activeworkbook.close() 

  ole_object.Application.Quit()

 ole_object.DisconnectObject()

 DESTROY ole_object

 

 //remove data file

 FileDelete(ls_file)

 ls_file = ''

 

 //gnv_app.ShellExecuteW ( handle( this ), "open", ls_existing_file, ls_file, ls_Null, 1)

  gnv_app.ShellExecuteW ( handle( this ), "edit", ls_existing_file, ls_file, ls_Null, 1)

  1. Helpful
  1. David Vasconcelos
  2. Wednesday, 10 May 2017 14:01 PM UTC
Chris, I was able to get it to work... for some reason all I had to do was put the shellexecute into a func/event and call it.  I am guessing it maybe some timing issue, but it now works....

  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.