Wednesday, September 18, 2019

Use Excel 2010 macro in some (not all) xlsx workbooks

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?

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...