Results 1 to 2 of 2
2009-10-07, 10:09 #1
- Join Date
- Sep 2008
- Thanked 0 Times in 0 Posts
I've created some Excel macros that I'm trying to attach to a particular spreadsheet. But it looks like they are being attached to my installation of Excel, and are showing up for every spreadsheet that I open. Also, they aren't showing up for people who have opened up my spreadsheet in their install of Excel.
In Word, attaching macros to the document versus the application is pretty easy, but I can't figure out how to do this in Excel. I've searched around but have had no luck.
2009-10-07, 10:20 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Word has an entirely different approach to storing macros, so it's not easy to mimic its behavior in Excel.
If you store a macro in a module in a workbook, that macro will only be available when the workbook is open. For macros that need to be available in all workbooks, you can use your personal macro workbook Personal.xls or an add-in (.xla file).
However, if you assign a macro to a custom toolbar button, that toolbar button will be visible in all workbooks by default. If you want it to be hidden if the workbook is not active, you have to write code in the Workbook_Activate and Workbook_Deactivate events in the workbook's ThisWorkbook module. You can also create the toolbar button in code when the workbook is opened and delete it when the workbook is closed (using the Workbook_Open and Workbook_BeforeClose events in the ThisWorkbook module)