+ Reply to Thread
Results 1 to 6 of 6

Macro storage location

  1. #1
    Registered User
    Join Date
    02-18-2009
    Location
    Apex, NC, USA
    MS-Off Ver
    Office 365
    Posts
    64

    Red face Macro storage location

    Macro Storage Location: I have an application I have developed and maintained in Excel 2003. I have written/recorded several VB macros for it. They are executed by my having assigned them to buttons on a toolbar I created. I periodically update the application and give it a new file name with a version modifier (eg application V6-9). I have done something I don't understand that I think is related to where the macro's are stored. After running any of the macros in the newest version of the application, I notice that Excel has opened a prior version of the application (not always the immediately preceding version, but maybe the last version that I happened to edit those macros.) and Excel is trying to use the version of the macro in that older version. I have gotten around this by re-doing the "assign macro" for each of the buttons and asking for it to allow me to select from "this workbook". I think I am missing some concepts here and some settings. I have looked in some manual and can't find explanations I understand which seem to apply. I want it to use the macros' version that is in the new version that has been loaded and is being used in production. Further, I don't want it to open the old version.

  2. #2
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro storage location

    Hi DanBlum;

    Obviously the macros assigned to the buttons have the old filename in them.

    I don't know if this will work on menu buttons, but you can try in the menus EDIT>LINKS. If there are no links to other files the "LINKS" option will be disabled (grayed out). If it's enabled then select the file that some links are pointing to and click "Change Source", then just select the workbook you're working in.

    The only other thing I can think of is to have Workbook_Open() create the buttons, so that they are always assigned the correct macro. You would either want Workbook_BeforeClose() to remove the buttons, or make sure that Workbook_Open() checks to see if the buttons already exists, and update the assigned macros. This is my preferred choice for all my workbooks.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  3. #3
    Registered User
    Join Date
    02-18-2009
    Location
    Apex, NC, USA
    MS-Off Ver
    Office 365
    Posts
    64

    Re: Macro storage location

    foxguy:
    Thanks for the reply. Yes, the buttons have the old file names in them.

    I do have another workbook linked to the subject workbook and use Edit->Links to manage the link. However, the linkage is not to an earlier version of the subject workbook, but to another workbook that has data that is referenced. This linked workbook does not have the marcros in it.

    Your second suggestion to me sounds like a pretty cumbersome work around that is mildly beyond my skill level at this point. I think I will wait to see if I an discover something simpler like a quick setting that I am not aware of.

    Let me pick your brain for a moment. Can you shed some light on the "Macro in" selection box at the bottom of the Assign Macro dialog box. Does that have any persistence so that when the workbook is subsequently opened it re-assigns all the macros based on the last setting of that field regardless of which macro was last assigned? I also note that in my list of "Macro in" is both "This Workbook" and also the fully qualified file name for the active workbook (namely the same as what I think "This Workbook" results in). Is there some subtle difference in whether I select "This Workbook" or the fully qualified name?

    Another subtley that I have not mentioned is that I run this workbook on other machines (other than the one I do the development on). Could the option of selecting "This Workbook" instead of the fully quallified name be there to allow for differences in the path name that exists on different machines? I think I notice, though, that when I go in and reassign a macro using the "This Workbook" list that when I reopen it later, the fully quallified name is, nevertheleess, in the assignment. Also what happens when I put the workbook on the "production" machine (as opposed to my development machine) and the path name is not the same? Could Excel have a memory of past successful assignments (with paths of the production machine), but older filename versions? This scenario, which I just "made up" fits the symptoms I'm seeing. However, it's not clear to me what to do about it (other than the second of the two suggestions you made).

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro storage location

    It's much betterto add the ToolBars within the code, do an Advanced Search on the forum for my name 7 Toolbars- you should find example files
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Macro storage location

    I do have another workbook linked to the subject workbook and use Edit->Links to manage the link. However, the linkage is not to an earlier version of the subject workbook, but to another workbook that has data that is referenced. This linked workbook does not have the marcros in it.
    Yeah I had my doubts that it would include menu buttons.


    Your second suggestion to me sounds like a pretty cumbersome work around that is mildly beyond my skill level at this point. I think I will wait to see if I an discover something simpler like a quick setting that I am not aware of.
    My gut tells me that this is the only way to solve your problem. Usually when people manually add buttons to their menus, they assign macros that are in their Personal.xls file, so they never need to update the macro assignment.
    When you are ready to venture into VBA created menu buttons, send me a PM and I'll help you get started.
    There is one possible way around your problem. If the old version of the file still exists and your macros keep running them instead of the macros in the current version, you could try this:
    Just assign a gateway macro to your buttons, and the gateway macro would run the macro in the ActiveWorkbook.
    Please Login or Register  to view this content.
    Just make sure there is a myGateWay and myActualMacro in every version. That way at least it would get to the most current version of the macro.


    Can you shed some light on the "Macro in" selection box at the bottom of the Assign Macro dialog box.
    The "Macro in" box is just a filter to help you find the macro you're looking for. I have 5 workbooks open at the same time with well over 300 macros between them all. When I need to assign a macro, that's the only thing that saves me. Half the time I can't remember the name of the macro I want to assign, so I need that "Macro in" box to help reduce the list I have to sort through.
    Is there some subtle difference in whether I select "This Workbook" or the fully qualified name?
    There is absolutely no difference at all between "This Workbook" and the full name. "This Workbook" is always 2nd in the list, right below "All Open Workbooks", so it's easy to find. Just about everybody wants to assign macros that are in the same workbook they are in, so they made it easy to find.


    Another subtley that I have not mentioned is that I run this workbook on other machines (other than the one I do the development on).
    When you assign a macro, Excel actually assigns the fully qualified name. If you move the workbook to another machine and it can't find the file in the correct place, it looks around for the file. If the file it's looking for is in the same folder, then it uses it, even though it has a different path than what was assigned. The path that gets assigned is basically just a starting point for Excel to start looking. In the old DOS days we used to "Set Path To myFolder, yourFolder, hisFolder, herFolder, etc." In those days the folders listed were the only place that Excel would ever look for files. Now I have no idea how they decide what folders to look in.
    However, it's not clear to me what to do about it (other than the second of the two suggestions you made).
    It's the only solution that I know of.

  6. #6
    Registered User
    Join Date
    02-18-2009
    Location
    Apex, NC, USA
    MS-Off Ver
    Office 365
    Posts
    64

    Re: Macro storage location

    Thanks for all the help. I will take advantage of your sugestions

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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