web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Execute .mac from VBA

(0) ShareShare
ReportReport
Posted on by

I have a .mac that clicks two buttons on a window.  This window was created by a consultant who is long gone so I don't have access to their code to see exactly what these buttons are doing.  However, I do know that they are doing what they are supposed to do, I just can't recreate their processes very easily, if at all.  The window is evidently restricted, because when I bring it into Dexterity, nothing is available to edit.

So, my solution was to write the .mac to click the two buttons.  Plus, I've written vba code to do all the logic testing and looping that I need, but now I need to execute the .mac.  After a lot of research and pain, I find out that doing this is not something vba can do very easily.  I've tried the following two methods:

1.  Sendkeys.  F12 is the GP shortcut for the macro:

    For Each i In EX_TC_Array
        TimeCode = i
        SendKeys "{F12}", True
    Next I

2. SanScript "Run Macro"

    For Each i In EX_TC_Array
        TimeCode = i
        Set CompilerApp = CreateObject("Dynamics.Application")
        MacroPath = "C:\Program Files (x86)\Microsoft Dynamics\GP2015\Macros\ATT_Looper.mac"
        Commands = "run macro "" & MacroPath & "";"
        ' Execute SanScript
        CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage)
        If CompilerError <> 0 Then
            MsgBox CompilerMessage
        End If
    Next i



Neither of these seem to be doing anything.  Running the F12 straight out of GP, the shortcut works, but in vba, it hits and processes these steps without error, but nothing happens.  I even moved the "SendKeys" logic to be the last step in my vba code thinking it was a processing timing issue, but it still did nothing.  Am I missing a setting within GP that would allow this kind of control?  Is there something wrong with my use of any of the code?  Or is there a better way (keeping in mind I can't use dexterity for this)?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    Don't waste your time with VBA.

    Solution: Have a fresh dictionary make a form/window in it and access the button functionalities of your old dictionary window  by using cross dictionary triggers.

    if you want to discuss my skype is : almasmahfooz

    Email Add: almasmahfooz@hotmail.com

  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,093 Most Valuable Professional on at

    You already have the Passthrough sanScript method to use Dexterity to run a macro from VBA.

    Is the a reason you don't use run script from Dexterity to "click" the buttons. You can use execute() if you need to go cross dictionary.

    I have lots of info on cross dictionary development on my old and new blogs.

    David

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Victoria Yudin Profile Picture

Victoria Yudin 1

#2
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans