Jump to content
Macro Express Forums

How To Count How Many Times A Macro Has Been Run?


Recommended Posts



I have several macros that I run quite often, and was wondering if it was possible to record how many times each macro was run for the day?


Is this possible? Any suggestions on how to implement this?


I'm a macro noob, so if you can keep it simple that would be great.



Link to comment
Share on other sites

If it were me I would save the count in the registry. I know it sounds intimidating to some but it’s super easy. Have the macro read an integer from the registry and then increment it and write it back each time the macro runs. Make a registry value for each macro. ME has a Misc section which I like to use for all kinds of variables I want to stash. Also handy to create preferences for macros. Have one macro edit preferences so the user can change them without being prompted every time.


Read Registry Integer: "HowManyTimes"
Variable Modify Integer: Inc (%N1%)
Write Registry Integer: "HowManyTimes"
Text Box Display: Result


<REGRINT:1:HKEY_CURRENT_USER\SOFTWARE\Insight Software Solutions\Macro Express\Miscellaneous\HowManyTimes><NMVAR:08:01:0:0000001:0:0000000><REGWINT:1:HKEY_CURRENT_USER\SOFTWARE\Insight Software Solutions\Macro Express\Miscellaneous\HowManyTimes><TBOX4:T:1:CenterCenter000278000200:000:ResultMacro has been run %N1% times>

Link to comment
Share on other sites

Keep a counter in the registry or in a file. Increment it each time the macro runs. There is a sample macro showing how to do this in the samples.mex file found in the folder where you installed Macro Express. Try this:


Open the Macro Express Editor. Click File, Open Macro File. Navigate to 'c:\Program Files\Macro Express3' and choose samples.mex. A menu should come up allowing you to choose from the sample macros. Try the macro named 'Counter from Run to Run'.


To see how it works, open the macro in the Scripting Editor. We do not recommend that you make changes to samples.mex. You should, instead, copy the macro to your regular macro file.


There are two ways to do this. One, you can highlight all lines in the macro, copy them to the clipboard, reopen your regular macro file, create a new macro or open an existing one, and then paste the macro commands.


Two, you can import this macro into your macro file. Reload your regular macro by clicking File, Reopen, and clicking on the name of your regular macro file. Then click File, Import, Import Macros. Navigate to 'c:\Program Files\Macro Express3\samples.mex'. Choose what macros to import and click the Import button.

Link to comment
Share on other sites

I can think of two other ways to keep track of how many times a macro runs. These methods do not 'count' the number of runs but instead put an entry in a 'log' file each time the macro runs.


You can enable logging for the macro by clicking on the Properties tab and selecting 'Use Log File'. This will put the date and time and name of the macro in the file specified by the Default Error Log file path. To see what this is set to click Options, Preferences, File Paths and look the the Default Error Log.


The other way to log is to put a Log Messages command at the top of your macro. You can either send the log entry to the default error log or you can specify a unique filename.

Link to comment
Share on other sites

  • 2 years later...

Is there a way to log when a .mex file is edited and changed? So every time someone add's a new Macro, makes a change, to the .MEX file, it will add that to the file? We have a shared .MEX file that everyone uses. Some is doing something and we want to be able to identify who. I have been able to create a macro that can pull username from the registry, I just need to figure out the rest.



Thank you very much for the help

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...