+ Reply to Thread
Results 1 to 6 of 6

Macro not working upon file name change

  1. #1
    Registered User
    Join Date
    07-04-2014
    Location
    london
    MS-Off Ver
    Office 2010
    Posts
    3

    Macro not working upon file name change

    Hi,

    I have an excel template that is macro enabled. However, when I save a new copy of the template under a different file name the macros are still linked to the original template name, is there a way to ensure that when a copy of the template is saved that the macros automatically update to that new file name and thus still work?

    Many thanks,

    Jaymie

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Macro not working upon file name change

    It shouldn't work like that. The code should not link to another file, if written properly. Can you either post the file, or show all the code? And describe what module contains what code?

    To post a file:
    1. Under the text box where you type your reply click the Go Advanced button.
    2. In the next screen look above the reply box and click the "paper clip" icon. You will get a pop-up screen.
    3. In the pop-up, click Add then Select to select a file from your local drive
    4. Click the Upload button to upload the file
    5. Click Done to attach it.

    It will be displayed as an attachment underneath your post text. Alternatively as the last step you can click the Insert Inline button and a hyperlink to the file will be inserted directly into your post text in the spot where your cursor is set at the moment you click the button.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    07-04-2014
    Location
    london
    MS-Off Ver
    Office 2010
    Posts
    3

    Re: Macro not working upon file name change

    I don't know if it possible but I have a template that people can use however have to save a new copy of the template to be able to use it. Ideally the macro that is in the template would be transferable to what ever the person changed the file name to.

    For example in the attached image "eeeeeeeeeeee.xltm" would become the new file name, therefore enabling the new macro to work?

    I hope this makes sense.

    Jaymie
    Attached Images Attached Images

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Macro not working upon file name change

    An image is not useful. Attach your file, or at a minimum paste in your code, and use CODE tags.

  5. #5
    Registered User
    Join Date
    07-04-2014
    Location
    london
    MS-Off Ver
    Office 2010
    Posts
    3

    Re: Macro not working upon file name change

    Please Login or Register  to view this content.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Macro not working upon file name change

    The correct way to use a template is to create a new Excel file using the template. Then you have a new file called Book1.xlsm that you can save. They should not be opening the template directly. If you want a file they can open directly then make a copy of, a different approach is required.

    If this file is used as a true template, then the following changes would be required for the code and the file name doesn't matter.

    Which worksheets in each of the workbooks do you want to work with? Explicitly identifying worksheets is much better than depending on what window is open. I have assumed that you are working with Sheet1 in both cases, but you will need to tailor that to your situation.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Code working as change event, but not as a macro.
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 20
    Last Post: 12-21-2013, 06:25 PM
  2. Macro to change filter settings not working
    By MugsyAU in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-08-2013, 01:50 AM
  3. macro not working on sheet change
    By David777 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-12-2011, 03:40 PM
  4. file name in macro not working
    By mrggutz in forum Excel General
    Replies: 2
    Last Post: 09-13-2010, 07:22 PM
  5. Macro has stopped working after date change
    By markrennolds in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-01-2009, 08:31 PM

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