Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Launch macro from GP window

Posted on by 75

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Launch macro from GP window

    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

  • Verified answer
    Teri Carpenter Profile Picture
    Teri Carpenter 75 on at
    RE: Launch macro from GP window

    That's exactly what I needed!  Thanks Leslie.

  • Verified answer
    L Vail Profile Picture
    L Vail 65,271 on at
    RE: Launch macro from GP window

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans