Print Page | Close Window

Run macro from toolbar button

Printed From: Zumasys
Category: AccuTerm
Forum Name: Scripting & Automation
Forum Description: Customize and control AccuTerm using scripts and automation
URL: https://forum.asent.com/forum_posts.asp?TID=2753
Printed Date: January 29 2022 at 3:39am
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: Run macro from toolbar button
Posted By: PSchellenbach
Subject: Run macro from toolbar button
Date Posted: October 19 2021 at 4:03pm
A user recently sent an email asking if it is possible to run a macro from a custom toolbar button. Here is the response:

Yes, you can add a macro to a toolbar button. I don’t think the syntax to run a macro from a toolbar button has been documented, and it took me a while to sort it out.

 

  1. Create and test your macro.
  2. If you don't remember your macro name, you can use Tools -> Macro -> Edit Macros. This opens the script editor, with the Macro tab selected. Each macro begins with Sub and ends with End Sub. At the beginning of each macro are comments with the macro name, shortcut and description. You can edit any of these to change the macro name, description or shortcut. After modifying the macro, use File->Save from the script editor window to save the changes.
  3. Open the menu designer from the Tools menu. Expand the Toolbar node. Click on the main Toolbar item. At the bottom, click the New button and select “normal button”.
  4. When the new button properties panel opens, add a tooltip if you want, and click Select Image to select an icon for the button.
  5. In the Action field, enter [#2999#NameOfYourMacro]. The square brackets [ ] are important.
  6. This causes the menu processor to execute the built-in command 2999, which is the value of the MACRO_RUN_LAST built-in constant. Since 2999 is in the range of MACRO_RUN_FIRST (2000) to MACRO_RUN_LAST (2999), the macro name after the 2nd “#” will be the name of the macro to execute. If you have multiple toolbar button macros, you could use 2998, 2997, etc. as the ID after the first “#”.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net