EXTRA! X-treme toolbar pointing to windows environment variables

I’ve scrapped together a few useful macros for work and added them to a tool bar for easy access.  A number of other employees would like to have my toolbar as well.  I would like to avoid going to each computer and changing the path of every toolbar button, so I tried to use windows environment variables.  The example below shows the original path to the macro, and how I attempted to resolve the issue when sending the toolbar and macros to other users.

OLD:  C:\Users\00000000\Documents\Attachmate\EXTRA!\MACROS\MyDir\Calc.ebm


NEW:  %USERPROFILE%\Documents\Attachmate\EXTRA!\MACROS\MyDir\Calc.ebm

Unfortunately using %USERPROFILE% on the run macro path in the toolbar does not function.  

Am I missing something obvious here or how can I resolve this issue?

  • Verified Answer

    Hi David,

    With the Extra! application open, if you have a look at Options - Global Preferences - Files/Directories Tab, you will see the default Macro search path.  If you place the macros in that default location (which is where they are created/saved by default), you do not have to use a path when you run the macro from your toolbar button.  Additionally, I note that your example macro is named "calc.ebm."  I don't know the full extent of your macro, but note that you can run an application directly from a toolbar button and don't need to have a button reference a macro to launch the application.


    Jeff B

  • Thanks, I will give that a try right now.  The calc.emb is fictitious file. I just put it there as a sample file name.  

  • Hi David, 

    An alternative would be to use a macro to launch the macro that you wish to execute, that way you can enumerate the environment variable in the initial macro to build the path to the macro which you wish to execute..

    So say you have a RunThisOne macro in your Application folder (i.e. C:\Program Files (x86)\Attachmate\EXTRA!\), then when you map your control to run that macro add a space and then the name of the macro in your myDir folder that you wish to execute.

    your RunThisMacro might look like this:

    hProcess As Long
    hThread As Long
    dwProcessId As Long
    dwThreadId As Long
    End Type

    cb As Long
    lpReserved As String
    lpDesktop As String
    lpTitle As String
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Integer
    cbReserved2 As Integer
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
    End Type

    Declare Function OpenProcess Lib "kernel32" Alias "OpenProcess" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
    Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

    Const SYNCHRONIZE = 1048576

    Dim sInfo As STARTUPINFO

    Sub Main

    Dim EBrunPath as String, MacroPath as String

    '*** Set the Path to Ebrun.exe
    EBrunPath = "C:\Program Files (x86)\Attachmate\EXTRA!\"

    Dim RunThisOne As String

    Dim sNull As String
    Dim lSuccess As Long
    Dim lRetValue As Long

    '*** Get parameter passed on the command line (in this instance, the name of the macro you wish to execute
    RunThisOne = Command$

    '*** Set that path to the centrally managed macros
    MacroPath = Environ$("USERPROFILE") + "\Documents\Attachmate\EXTRA!\MACROS\MyDir\"

    '*** Execute the command to launch the relevant macro and wait for it to terminate before exiting
    sInfo.cb = Len(sInfo)
    lSuccess = CreateProcess(sNull, EBRunPath + "Ebrun.exe "+ MacroPath + RunThisOne, ByVal 0&, ByVal 0&, 1&, NORMAL_PRIORITY_CLASS, ByVal 0&, EBrunPath, sInfo, pInfo)

    Do While lSuccess > 0

    nn = GetExitCodeProcess(pInfo.hProcess, nExitCode)
    If nExitCode = 0 Then lSuccess = 0
    RunAndReturn = 0
    RunAndReturn = 1
    End Sub

    This way you can completely isolate your myDir macros and users can't inadvertently screw things up by accidentally changing their default macro path. 

    This may not work for you if you have roaming users, which is likely why you have not just dropped your macros in a common location in the first instance.

  • I would actually prefer to define path at startup so i could keep my file folder Organization.  However my company has an elaborate startup that we are not permitted to alter or run any other startup scripts.   Thank you for the information though as I’ll use this in a different project that I am permitted to make changes on.