Custom UI lock SAGE 300 from exit

SOLVED

Hi,

Is it possible to lock Sage Desktop from exiting when we run a custom .exe program?
If we run a custom macro and try to exit Sage, there will be a prompt to close the opened window first.
But for an .exe program, there is no such prompt. 
Is there a way to code the program to get the same prompt as a macro?
Thanks for your assistance!

  • +1
    verified answer

    The easy way is to create a macro that will run your program that won't end until the program ends.

    Another way is to make use of the $objecthandle$ parameter which, I pretty sure, will do what you need.

  • 0 in reply to Django

    Hi Django,

    Thanks for your reply.

    I have tried both methods.

    1. When I create a macro that calls the .exe, Sage desktop still allow to exit without prompting the opened window. This is my function call..is it correct? 
    Do I need to add anything else to get it working as per a normal macro?

    Sub MainSub()

    Call Shell( myfiilepath, vbNormalFocus)

    End Sub

    2. I have tried the $objecthandle$ parameter as per Stephen Smith's blog
    (https://smist08.wordpress.com/?s=objecthandlebut could not pass CreateSession line which throws a "Session is not initialized error"

    strObjectHandle = Command$

    lACCPACSignonID = 0 
    Set ACCPACSessionMgr = New ACCPACSessionMgr
    With ACCPACSessionMgr
    .AppID = "XY"
    .AppVersion = "64A"
    .ProgramName = "XY1000"
    .ServerName = "" 
    .CreateSession strObjectHandle, lACCPACSignonID, ACCPACSession 
    End With

    I passed $objecthandle$ in my command line argument.

    Am I missing anything?

    Thank you for your kind attention and assistance.

  • 0 in reply to h@AIT

    Have you initialised the ACCPACSession  object?

    I normally don't use that Session Manager object and use the AccpacSession object directly.

    Something like:

           static AccpacCOMAPI.AccpacSession _session;

            private static void OpenSession(string objHandler)
            {
                _session = new AccpacCOMAPI.AccpacSession();
                _session.Init(objHandler, "XY", "XY1000", "66A");

                if (string.IsNullOrWhiteSpace(objHandler))
                {
                    _session.Open("ADMIN", "ADMIN", "SAMINC", DateTime.Now, 0, "");
                }
            }

  • 0 in reply to SergeB

    Hi, yes I have used an ACCPACSession.

    Thanks. 

  • 0
    SUGGESTED

    For anyone interested, I manage to do this by Django's answer to create a macro that will run the program, but the macro has to run some other functions in addition to calling the program.

    Thanks!