Thomas Wilkins
Thomas Wilkins

Reputation: 25

Triggering external macro on button click from normal excel workbook (.xlsx)

Stated simply my question is as follows Is it possible for a button on a worksheet in a normal excel workbook (.xlsx not .xlsm) to trigger a macro in another file specifically an installed excel add in (.xlam).

Here is some background on why I want to achieve this. I have a workbook that many users need to be able to view but only some need to be able to update by filling in a form on another sheet and calling a macro in an add in. The worksheet should not contain any macros to avoid security warnings when opened by normal users. I can do this by having a ribbon button in the add in that the user clicks which will then check that the correct workbook is open and that the form is filled in etc. before executing the update code. However the interface would be nicer if the button instead of appearing on the ribbon was on the worksheet just below the form. Therefore my question is it possible to trigger an external macro from a button click in a non macro enabled workbook.

Upvotes: 0

Views: 2795

Answers (2)

Catherine
Catherine

Reputation: 31

Yes, you can assign an external macro (which should be .xlsm file) to a non-macro-enabled workbook (.xlsx) button. My xlsm macro resides in the same directory as the xlsx workbook for simplicity. (Note: I am using Excel 2010)

  1. Firstly, you must open your xlsm macro in the same instance of Excel window (i.e. do not open a new instance of Excel) so that your xlsx workbook will be able to see/access it.
  2. Right-click on your xlsx workbook button and select "Assign Macro..."
  3. Make sure you select Macros in: All Open Workbooks
  4. All macros in open workbooks will be shown (this is why it is important to do step 1).
  5. Select the desired macro from the list then click OK.

Upvotes: 3

Charles Williams
Charles Williams

Reputation: 23550

I don't see how you can execute a macro from a control in a non-macro-enabled workbook.

Upvotes: 1

Related Questions