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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Launch macro from GP window

(0) ShareShare
ReportReport
Posted on by 77

Hi,  I'm trying to launch a gp macro from a new button on a GP window.  I've added the button but not sure of the syntax to launch the macro in VB Editor.  Has anyone done this?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    L Vail Profile Picture
    65,271 on at

    Please take a look at this thread. I think it is exactly what you need.

    https://community.dynamics.com/gp/f/32/t/39242

    Mariano Gomez posted this:

    Add the following code to your VBA event:

    Dim CompilerApp As Object
    Dim CompilerMessage As String
    Dim CompilerError As Integer
    Dim Commands As String
    Dim MacroPath as String

    ' Create object without having reference marked
    Set CompilerApp = CreateObject("Dynamics.Application")
    MacroPath = "C:\SomeDirectory\SomeMacro.mac"

    Commands = "run macro "" & MacroPath & "";"

    ' Execute SanScript
    CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage)
    If CompilerError <> 0 Then
    MsgBox CompilerMessage
    End If

    Best regards,

    Leslie

  • Verified answer
    Teri Carpenter Profile Picture
    77 on at

    That's exactly what I needed!  Thanks Leslie.

  • Community Member Profile Picture
    on at

    Hello Leslie,

    I am experiencing an issue when using this VBA code to open a macro. I see error message "cannot open macro file". I am an administrator on our GP server and have tried multiple locations to place the macro file. The macro runs successfully when I choose Tools-->Macro-->Play. Any ideas on if there is a file network security piece to this?

    Thank you,

    Justin K

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans