+ Reply to Thread
Results 1 to 5 of 5

How to create a macro not specific to one file?

  1. #1
    Registered User
    Join Date
    05-07-2004
    Posts
    33

    Question How to create a macro not specific to one file?

    Is there a possibility to create a macro that's not specific to one file or one workbook? I want to create a macro that works like the AutoSum button. I've created this macro under one workbook and created a custom toolbar and button for this macro. However, when I closed the file and open another workbook or file, this button is not working. When click on the button, the file that I have the codes on open up and start running the macro but not the workbook or file I originally wanted the macro to run on.

    Any help is appreciated.

    ljCharlie

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,468
    Easiest way is to save your macro in your personal.xls workbook in the XLstart folder.

  3. #3
    Registered User
    Join Date
    05-07-2004
    Posts
    33
    Thanks for the help, but I still could not get it to work. I did save the file as .xla, went to Tools/Addins/check on the appropriate choice, click OK and nothing happens. Are there more to the instruction then this because I could not get the button to show up on the toolbar for user to click on it and run the macro?

  4. #4
    Registered User
    Join Date
    05-07-2004
    Posts
    33
    Okay, my code runs if I created a button and assinged the macro to the file e.g. demo.xls. When I open the file demo1.xls and click on the button I just created, Excel then automatically opens the file demo.xls but the macro runs on the demo1.xls file instead of the demo.xls file, which is nice but it would be nicer if the file demo.xls is not even open at all.

    One other thing, once I added the add-in, how do I run or use the add-in I just added? There is nothing showing in the menus.

    ljCharlie

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,468
    I have a spreadsheet with a macro that I want available to all open workbooks with an associated toolbar and button. When this workbook is opened (either as .xls or .xla, I've done it both ways), I put an Auto_open procedure in it that sets the accompanying toolbar.visible property to true. Then I have an auto_close that hides the toolbar when that workbook is closed (or the add-in unchecked). Then, whenever that workbook is open, I have the toolbar button available, which causes the associated Sub procedure to run on whatever worksheet is currently active.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1