Macros don't work when file name changes

I created a workbook with many macros using the simple "record macro" tool. 
This fiel was saved in *.XLS format. It is intended to be a master fille and 
when you fill it out as a form you re-save it with a new name.

the problem I am running into is that after I re-save it wit a new name the 
Macros won't work properly. I get an error message and when I click to run 
the debugger the macro lists the original workbook name.

How do I fix this so that the macros work regardless of file name?
0
Utf
1/13/2010 5:31:01 PM
excel.misc 78881 articles. 5 followers. Follow

2 Replies
1688 Views

Similar Articles

[PageSpeed] 25

Without seeing the code, my guess is that the macro recorder put
explicit file names in the code, e.g., Windows("Book1.xls").Activate.
You need to modify the code so that it will reference the
ActiveWorkbook instead of a specific named workbook.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]




On Wed, 13 Jan 2010 09:31:01 -0800, Chuck Sena <Chuck
Sena@discussions.microsoft.com> wrote:

>I created a workbook with many macros using the simple "record macro" tool. 
>This fiel was saved in *.XLS format. It is intended to be a master fille and 
>when you fill it out as a form you re-save it with a new name.
>
>the problem I am running into is that after I re-save it wit a new name the 
>Macros won't work properly. I get an error message and when I click to run 
>the debugger the macro lists the original workbook name.
>
>How do I fix this so that the macros work regardless of file name?
0
Chip
1/13/2010 7:11:13 PM
It could depend on how you run the macro--or what object you assigned the macro
to so that you could run it.

On the other hand, it could depend on how the code is written.

If it's the first, then you'll have to share what you use to run the macro--a
shape placed on a worksheet or a button on a toolbar/QAT/Ribbon.

If it's a button on a worksheet, did you use the button from the Forms toolbar
or a Commandbutton from the control toolbox toolbar.

Does it run ok if you use Tools|Macro|macro|run (in xl2003 menus).

If it's the second, then maybe just rewriting the offending code to use the
activesheet would fix it.

But those are just guesses.

You'll get better answers if you supply more info--and if it's the code, you'll
get better answers if you share the code--and indicate what line caused the
trouble.



Chuck Sena wrote:
> 
> I created a workbook with many macros using the simple "record macro" tool.
> This fiel was saved in *.XLS format. It is intended to be a master fille and
> when you fill it out as a form you re-save it with a new name.
> 
> the problem I am running into is that after I re-save it wit a new name the
> Macros won't work properly. I get an error message and when I click to run
> the debugger the macro lists the original workbook name.
> 
> How do I fix this so that the macros work regardless of file name?

-- 

Dave Peterson
0
Dave
1/13/2010 7:11:33 PM
Reply:

Similar Artilces:

Maximum file sizes
Is there a recommended maximum file size for Excel 2000. PC spec 2Ghz P4 with 256 Mb Any advice appreciated Deus -------------- Does Not Exist Hi have a look at http://www.decisionmodels.com/memlimits.htm -- Regards Frank Kabel Frankfurt, Germany "Deus DNE" <deus.dne@ntlworld.com> schrieb im Newsbeitrag news:1561701c41d4f$358950f0$a001280a@phx.gbl... > Is there a recommended maximum file size for Excel 2000. > > PC spec 2Ghz P4 with 256 Mb > > Any advice appreciated > > Deus > -------------- > Does Not Exist ...

excel database 25,000 plus names #2
I am working with a database i set up in excel. It has over 25,000 names, total size of file is 274mb. If i transfer all my data from an excel database to access, will i work faster. Right now it takes forever to open and save. I am told it is not my computer. any tips??? -- mikedipaol ----------------------------------------------------------------------- mikedipaola's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3568 View this thread: http://www.excelforum.com/showthread.php?threadid=55465 ...

File size #11
I have read the other discussions on file sizes but they do not seem to address my problem. I have an Excel file that is 12mb large with low-res jpegs in it. This file also has merged cells to make it look pretty. Does Excel look at these merged cells as graphics? Is this why they are too big? I have run a macro to make sure that it goes to the last cell. How can I get the file smaller? How big are the graphics? If you remove them from the file, what is the size of the file and what is the size of the graphic files? To be sure you do not have extra formatting, if you open the file...

find action on log file
Hello there I want to use outside tool to find who made some update on table in my server I know that there are many tools for this. But can they do it on simple recovery model? Roy Goldhammer (royg@yahoo.com) writes: > I want to use outside tool to find who made some update on table in my > server > > I know that there are many tools for this. But can they do it on simple > recovery model? No. If you are using the simple recovery model, the contents of the log is wasted away everyonce in a while. Well, if the disk area has not been overwritten...

Linking files 2 ways
I have a work book that is linked to another and vise versa. As thus: Workbook A is where the input of data is made; Workbook B has a link to the input from workbook A; Workbook A retrieves the altered data back as a link. Although this all works fine with both books open, I note that if I open workbook A by itself, that the data it retrieves from Workbook B is not updated . If However, both books are open, there's no problem. I thought linked books were updated automatically if the Update remote references has been selected?? But it appears that the second book is not updated until it ...

How to repair a .dll file in IE8
Several days ago I noticed in my Dependency Walker that the IESHIMS.dll files has a yellow circle with a question mark on it. What does this mean and How do I repair it? OS: Windows Vista Home Premium Browser Internet Explorer 8 -- TW Hi, See the History tab on that dialog. A web search for ieshims.dll files will also help you find a solution for that file. Regards. "TW" <TW@discussions.microsoft.com> wrote in message news:63E61463-D766-4ABC-B081-BFA8C04FB159@microsoft.com... > Several days ago I noticed in my Dependency Walker that the IESHIMS....

OL2007 not move big files from outbox to sent
Hi, We have 2 computers with separate email accounts on Roadrunner. One machine has XP with Outlook 2002-sp3 and works without any problems. The other has Outlook 2007 on Vista and has problems sending files over a meg or so in size. It seems to actually send the file but the file remains in the outbox folder and does not move it to the sent folder. I say it "seems" to send the file because some people complain of getting muliple copies and others don't seem to get them at all. If I hit send again (not set up for auto send) it seems to send the file again (why some ...

Using Relative path for XML data file?
Is there a way to specify a relative path to an XML data file imported into Excel 2003? I am writing a web app that generates report data as XML for the user to download to their local machine. This data is to be consumed by an Excel reporting spreadsheet, which contains display-formatted tables and charts that are mapped to various data fields in an XML Map, which is in turn linked to the xml data file they will download. The idea is the user only needs to download the data for updates, not the whole spreadsheet. However, since I cannot predict the path where the user will store their...

Changing Cells and entering data in them
Thanks for the help again. Big thanks to Steve you've got me this far. I went out and bought a book, but it's like reading a foreign language. I was informed today that I can't have message boxes come up. I need to have the code point at the cells and if they are blank turn which ever one is blank red or if both are then both turn red then pause for each cell to be filled in. Cell F14 "Last Name" then automatically go to Cell F16 "First Name" on tab or enter. Basically if Cell F22 or F23 has an X in it, Cells F14 an F16 turn red and cell F14 has the focus...

How to automate increasing the form cache registry/file etc...
I want to roll out a batch file to make a number of tweaks to CRM The body of it would go REGEDIT /S Kerberosefix.reg REGEDIT /S ForceFormreload.reg REGEDIT /S OutlookFix.reg It would also rename OSA.exe to OSA.bad Remove OSA.exe From the startup menu I need help finding a way to use my batch file to increase the Outlook Form cache from the default 4MB to 50 MB.. This makes CRm more stable and faster for communications. I dont want to manually do this, as it time consuming, are my end users would not be reliable in doing it themselves. I also want to make another batch file or button that...

unsolicited entry in the folder "Temporary Internet Files"
Hello, I am working on a programme which browses web sites and runs under XP. The http download is as follows: pServer = Isession -> GetHttpConnection(strServerName, nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags); pFile->SendRequest(); pFile->QueryInfoStatusCode(dwStatusCode); if(dwStatusCode == 200) { pFile -> QueryInfo(HTTP_QUERY_LAST_MODIFIED, &sysT); status.lastMod = sysT; if(DBlastMod == status.lastMod) //URL content has not changed since the last visit ...

Change position ID in HR
We would like to change the position ID in human resources. Does anyone have a suggestion on this. You would need to do it behind the scenes using a tool like Query Analyzer. -- Charles Allen, MVP "KT" wrote: > We would like to change the position ID in human resources. Does anyone have > a suggestion on this. careful though when you change it on the background as you need to know all the tables that use this position ID or Position Code and change it there too otherwise all the link would be gone and you end up with orphan records that its just the same as creatin...

I need a macro
I would like a macro to do the following: I would place the the cursor in any cell and this macro would give me the average of all the entries to the left if the selected cell. EX: I place the cursor in cell M12. I want this macro on display in cell M12 the average of all the values from Col C12 to Col L12. Note that there may NOT be entries in all the cells in that range. Also the start point would always be col C .Thanks You can do this easily with a worksheet_selection event in the sheet module but you would probably want to restrict to a certain range or columns and rows or it woul...

CSV Files and VLOOKUP error
Does anyone know why VLOOKUP and Compare formulas don't work o information originating from a CSV file? I've tried copying an pasting values only (to leave behind any formatting), but it doesn' help. Through countless tests, I've narrowed it down to the CSV file bein the only possible cause -- Message posted from http://www.ExcelForum.com Hi ajpowers, Just a guess but the imported data may have leading or trailing spaces or are numbers stored as text. You could use the formula =A1=D1 to see if you get a true or false, where A1 is the lookup value and D1 ia the CVS valu...

Filters not working in Exchange 2003
I have been trying to turn on the Recipient, Connection, and Sender filters. I have gone to the Default SMTP Virtual Server and turned it on there without getting an error but when I go to the Properties and add senders to block and the hit Apply, it tells me that I must manually turn the filtering on in the SMTP VS. I have stopped and started the Default SMTP VS but still no luck. Any ideas? Hi Wayne That is a standard dialog box, it does not check to see if it is already enabled, have you tested the sender filtering? -- Mark Fugatt Microsoft Limited This posting is provided &quo...

How do you change the APR?
How do you change the APR in a Credit Card account? Like if you have to change it from 13.250% to 14.240% Depends on the version but (in M2007) go to the CC Account and click on Change Account Settings. Scroll down to Credit Information and click on Change Credit Details. If you want to change the Minimum payment rate/amount as well, click on the Minimum payment amount and a side window opens. -- Regards Bob Peel, Microsoft MVP - Money For UK tips & fixes see http://support.microsoft.com/default.aspx?scid=fh;EN-GB;mny. I do not respond to any emails that I have not specifically ...

After editing example1.xls and click SAVE, the filename changes to AABBEE.xls
After editing example1.xls and click SAVE, the filename changes to AABBEE.xls. The original file still exist and has been updated but the 'funny' filename also have the same content, and editable. The example1.xls is stored in a server and accessed by many people within the company. Everyone accessing to the file will change the filename unknowingly after saving it. ...

Problem with named range for a large spreadsheet in Excel 2007
Hello, I am trying to generate a large Excel spreadsheet apprx. 10000 rows and 40 columns. I am generating defined name section in the Workbook.xml part of the XLSM package. Here is a sample entry from that section <definedName name="_._44802_._0_._0_._0_._top_line" localSheetId="0" hidden="1">Sheet1!$B$2</definedName> Although the generation goes fine, I can not open the spreadsheet as the Excel throws an error message saying the package is corrupt. But this is not the case if the spreadsheet is small say, 200 rows by 10 columns. ...

Business Portal Development
All: I know how to use Rational XDE, VS and the BP SDK to create new entities in BP, but how does one go about chaning labels? For example, if I wanted to change two labels on a requisition mgt screen: Can I just crack open the ASPX page and change the caption property? Thanks, Dwight -- Hi, To edit the lables you can use front page server extensions 2003. "Dwight Specht" wrote: > All: > > I know how to use Rational XDE, VS and the BP SDK to create new entities in > BP, but how does one go about chaning labels? > > For example, if I wanted to ch...

Rule won't work
Outlook 2007 I have set up a rule to do the following; When I send or receive a message from a specific contact, play a sound, display in new item alert window, flag for follow up and move to a specific folder. But it is not doing anything. Do I need to change something else? What type of email account? Do other rules work? Does it work if you use any one action? -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subscribe-request@lists.out...

Search media files
I have WMP 11 on Windows XP SP3. I have recently move all my music on an external hard disk. Now that I want to search the media files so that it changes the file path and I can listen to my music, it seems that there is no search media files in my Tools menu. What am I doing wrong? On Sun, 14 Mar 2010 14:22:01 -0700, newsy <newsy@discussions.microsoft.com> wrote: >I have WMP 11 on Windows XP SP3. I have recently move all my music on an >external hard disk. Now that I want to search the media files so that it >changes the file path and I can listen to my music, i...

Trouble in Save existing file
Hi there, I am using GetSaveFileName(), OnSaveDocument() to save configuration file of my application. Trouble is when I open existing file, edit, and try to save it as the same name, it compains like "Access to file was denied" and I can't save it. But it can be saved as a new name by SaveAs menu. One other thing is this trouble is happening only in Window2000 PCs. It just works well in Window 98. The application is developed in Windows 2000 and I am using Flags like OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; Please help. Bob NZ >Hi there, I am using GetSaveFileName(), OnSaveD...

Any way to open an excel file directly to a worksheet?
I am building an application with an icon that launches an excel file when clicked. Is there any way I can open the file directly to a specified worksheet? The names of the worksheet are fixed and so is the file, so I am guessing adding some parameter after the filename should do the trick. Any help will be appreciated. Regards Sid -- skiddyrow ------------------------------------------------------------------------ skiddyrow's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=23965 View this thread: http://www.excelforum.com/showthread.php?threadid=386335 Hey...

How can I change text to proper text in multiple cells.
I need to change names that are all in caps to proper case in 100 cells. If I click each one individually, it works, but I need to be able to perfomr this funcion automatically on all the cells. One other post said to be sure calc is set to automatic and mine is. Any instruction is most appreciated. Thank you. Insert a helper column to the right of the column with the names. Then use a formula like: =proper(a1) and drag down that column Then select that column edit|copy select the original range Edit|paste special|Values And then delete the helper column. bethye99 wrote: > > I...

Changing Domain Name through Internet Address Management Wizard
Hi Guys I know its weekend. but i need to post for peace of mind. I have a client using SBS 2008 STD.He isusing remote.mydomain.com address through Internet address management wizard. Now he wants to change to remote.mynewdomain.com as old domain is too long. Is there any way so we can change through IAMW. run the wiz, job done. "Atul Sood" <atulsood@live.com> wrote in message news:uVlbmkd3KHA.4028@TK2MSFTNGP05.phx.gbl... > Hi Guys > > I know its weekend. but i need to post for peace of mind. I have a client > using SBS 2008 STD.He isusing rem...