Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a macro that I would like to use in some XLSX workbooks, call them wb1.xlsx and wb2.xlsx. Because they are XSLX they cannot contain any macro definitions.

My first choice to accomplish this was to use the Personal Macro Workbook in the XLSTART directory. However, I prefer that this not be global, that is, I do not want every workbook to access this macro, rather I would like only wb1.xlsx and wb2.xlsx to access the macro.

My next attempt was to define my macro in an Add-In, call it:

%APPDATA%\Microsoft\AddIns\MyMacros.xlam

I checked the MyMacros item in the Manage Add-Ins list for wb1.xlsx, and then saw it was already there for wb2.xlsx. I then unchecked the MyMacros item in the Add-Ins list because I didn't want any future workbooks using it, but when I tried to open wb1.xlsx afterwards I received the error message:

Cannot run the macro "mymacro". The macro may not be available in this workbook or all macros may be disabled.

The reason for this is because MyMacros.xlam was no longer in the Add-Ins list. Apparently any change to the Add-In list is global rather than a property of a particular workbook.

Does anyone know of any other way to access a macro from some (not all) XLSX workbooks?

share|improve this question
add comment

1 Answer

You could save the macro in an .xlsm file and then save that macro enabled file plus your wb1.xlsx and wb2.xlsx as a workspace file (*.xlw). You can then open the workspace file, which will open all three workbooks in one swoop.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.