1. Cesar Armando Garcia Liñan
  2. PowerBuilder
  3. Friday, 11 December 2020 17:50 PM UTC

Hello. We are migrating a client/server desktop application from PB 17 to PB 19. Some of our OLEObject functionality appears to have broken, and I'm looking for some help.

Here is a snippet of the code in question:

String str_run

OleObject wsh

Integer li_rc

 

wsh = CREATE OleObject

li_rc = wsh.ConnectToNewObject( "WScript.Shell" )

IF li_rc < 0 THEN

    messagebox("error","error de Conexión con PSPAD")

         RETURN False

END IF

//result = myoleobject.ConnectToNewObject("excel.application")

str_run = GetCurrentDirectory()+'\pspad\PSPad.exe ' + str_file_name + ' -h'

wsh.RUN(str_run)

 

Sleep(1)

wsh.sendkeys("{INSERT}")

wsh.sendkeys("{DEL}")

wsh.sendkeys("{DEL}")

wsh.sendkeys("{DEL}")

wsh.sendkeys("^{S}")

wsh.sendkeys("^{F4}")

wsh.sendkeys("^{F4}")

wsh.DisconnectObject()

RETURN True 

 

In PB 17, everything works as expected. In PB 19, I get the following error:

Power Builder application execution error (R0035) Application terminated. Error: Error calling external object function run at linea 13 in function gf_quita_bom_file_hex of gf_quita_bom_file_hex (wsh.run(str_run))

 

Any thoughts? Thank

Govinda Lopez @Appeon Accepted Answer Pending Moderation
  1. Friday, 11 December 2020 17:57 PM UTC
  2. PowerBuilder
  3. # 1

Hi Cesar,

 

Did you perform a full build and optimize of each library after migration? This helps quite often.

 

 

Regards,

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 11 December 2020 19:31 PM UTC
  2. PowerBuilder
  3. # 2

Hi Cesar;

  FWIW: My frameworks use the "WScript.Shell" implementation and are not having any issues in PB 2019 - even 2019 R3 beta. However, I do not use your way of sending commands to Excel via the MS-Windows "shell". Instead, I use a FindWindow() API call to get Exel's "handle" and then use the PB built-in SEND() command to send Excel the key commands as required.

  However getting back to your implementation ....  have you tried running your posted code through the PB IDE's "Debugger" step-by-step to see where & how it breaks?

  Tip: You might also get more information on the problem if the debugger route fails to expose the runtime issue by wrapping your code in a TRY..CATCH command block. Sometimes "Exception" thrown can often can contain more helpful information.

HTH

Regards ... Chris

Comment
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.