Can I create macros in modular form?

I have several macros that have several similar parts. Is it possible to create a module so that each of the separate macros can invoke the module, thereby reducing the length of each of the macros?
Is it possible for a macro to trigger another macro? Thanks.

Yes, I do that quite often.
See the "Execute a Macro" Action in the "Execute" group.

AFAIK, KM does not provide for macro parameters to pass data to/from the "sub-macro", so I just setup some KM Variables, some set by the calling macro, and some (usually just one) set by the "sub-macro".

Yep! As @JMichaelTX mentioned, the “Execute a Macro” action is very useful. The one caveat is that if you ever delete one of the macros in your chain, it will break the workflow. This can become a problem if you’re not careful in how you design each macro.

I think it’s best if you take this approach, to have each macro do one thing well and no more. That way, if you need to change something later on, the amount of refactoring you’ll need to do should be minimized.

If you’d like to see how I’ve taken this modular approach, see both of these articles and their Github repos:

@peternlewis, I do wish that there was a check in KM that would notify of the deletion of macros that are use by other macros. Is that something we can have for the next iteration?

Good point, Chauncey.

The way I have dealt with this issue is two-fold:

1. Name each KM Macro that is designed to be called by another Maco using a prefix that includes "SUB". This helps clearly identify this macro as a "subroutine", if you will. :smile:

For example, I have these SUB macros that I use with my Outlook (OL) macros:

  • OL SUB Find & Copy Line
  • OL SUB Set Recipient to EN EMail

2. I include a "Comment" Action at the top of each Macro that requires a SUB macro that clearly identifies the required SUB.

For example:

Hope this will be of some use to all.

1 Like

Its not scheduled for 7.0 I'm afraid.