Macro does not save with Excel Template

Posted on 2011-10-07
Last Modified: 2012-05-12
I have created an Excel 2003 template file and a macro assigned to a toolbar button.  The macro saves the template as a CSV file (hotfile.csv) and closes the application.  The next time I open the template file (hotfile.xlt), I click on the macro button and it tells me that it can't find the hotfile.csv macro.

What happens is the macro button is re-assigned to the CSV file during the SaveAs process.  

How can I keep the macro assigned to the toolbar button in the template (Hotfile.xlt)?
Question by:BartowIT
    LVL 3

    Expert Comment

    If i understnad your problem correctly you need to choose the Macro Enabled Template (*.xltm) option
    LVL 17

    Expert Comment

    It won't be the macro enabled thing because you are on Excel 2003.  It sounds as though you are somehow saving your template file after doing the csv save as.  This should not happen if you are using the template correctly - you must open it with File...New, or right click on it and choose New - NOT Open, which opens the template itself.  You should get a new .xls file based on the template when you open it, then the underlying template won't get changed.

    Author Comment

    My only option is to use Excel 2003 files, so xltm won't work.  

    I'm sure it's sometihng in my VB, as I had a file once before that worked just fine.  I need the macro to stay with the XLT, not the CSV file.  It's quite strange.

    Accepted Solution

    It appears this is a problem with Excel?  I installed Excel 2007 the script works.  

    The line that was throwing me off in 2003 is ThisWorkbook.SaveAs Filename:


    Author Closing Comment

    Installing 2007 was a work around

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asseā€¦
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
    This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now