How to create an objecthandle object without passing parameter $objecthandle$ from the macro?

SOLVED

HI,

Is there a way to programmatically code an objecthandle without passing it as a parameter in the Program Argument?

Here is the scenario:

1. I have a vb6 program (.exe) that is supposed to run on Sage 300. This .exe program passes $objecthandle$ as part of the parameter so that the program does not need to prompt for multiple companies opened on Sage 300 desktop.

2. I created a macro to call this .exe program with some additional features so that Sage 300 cannot exit if this macro is still running.
(The .exe program does not stop Sage 300 from exiting, so I had to use this macro to call the .exe instead)

3. I cant seem to pass the $objecthandl$ as a parameter to open the .exe program from the macro.

4. Is there a way to code this objecthandle object instead? 
Is it by using the AccpacSession.CreateObjectHandle function?
I do not know what parameters to pass in to the function call: 

CreateObjectHandle(objectID As String, ObjectKey As String, ObjectHandle As String, CLSID As String, Codebase As String)

Does anyone have any examples?

Thank you for your assistance.

  • +1
    verified answer

    I'd go with CreateObjectHandle2.  The first parameter will be a RotoID that the user has access to (like the fiscal calendar or an OE screen (OE1100) if your .exe plans to open an order entry screen) and the second parameter can be blank.

    Something like this which looks for a command line parameter of /OH:1 (assuming that 1 was generated by $objecthandle$ and if the program was run without the OH command line parameter then I generate my own object handle.

    760       If GetCommandParamValue("OH") = "" Then
    770           code_SageLink.OpenAccpacSession
    780           MyObjectHandle = accSession.CreateObjectHandle2(SCREEN_ROTO_ID, "")
    790       Else
    800           MyObjectHandle = GetCommandParamValue("OH")
    810           Set accSession = New AccpacCOMAPI.AccpacSession
    820           accSession.Init MyObjectHandle, "XY", "XY0001", "65A" '2018
    830       End If

  • 0 in reply to Django

    Thanks for all your help Django for both queries!

    Its working now.