ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Recorded macro: What happens if I change filename? (https://www.excelbanter.com/excel-discussion-misc-queries/10014-recorded-macro-what-happens-if-i-change-filename.html)

[email protected]

Recorded macro: What happens if I change filename?
 
Hi everyone,


Say I have a recorded macro named "Base" and linked it to a button in a
an excel workbook named ABC.xls

Later, say I changed the file name to DEF.xls


Now, when I click on the button to execute, I get "out of range"
error and the file close!


How can I make the macro name is independent of the file name; so it
doesn't keep referring to the old file name?


Regards,
Mike


JulieD

Hi Mike

two questions,
1) where are you saving the macro - is it in the ABC workbook or in your
personal workbook?
- if you want the macro to be available to a number of different workbooks
it needs to be in the personal macro workbook not in a specific workbook (it
can be in a specific workbook, but this workbook must be open if you want to
run the macro)

if that's not the problem
2) could you please copy & paste the code in a reply post so that we can see
where and how the filename is being used in the code

Regards
JulieD



wrote in message
oups.com...
Hi everyone,


Say I have a recorded macro named "Base" and linked it to a button in a
an excel workbook named ABC.xls

Later, say I changed the file name to DEF.xls


Now, when I click on the button to execute, I get "out of range"
error and the file close!


How can I make the macro name is independent of the file name; so it
doesn't keep referring to the old file name?


Regards,
Mike




Dave Peterson

You could reassign the macro to the button each time the workbook is opened.

Or maybe just rename DEF.xls back to ABC.xls, then open ABC.xls and do a
File|SaveAs (instead of using windows explorer to rename the workbook).

If that doesn't work, post some more details. What kind of button? On a
worksheet from the Forms toolbar? Or on a toolbar?



wrote:

Hi everyone,

Say I have a recorded macro named "Base" and linked it to a button in a
an excel workbook named ABC.xls

Later, say I changed the file name to DEF.xls

Now, when I click on the button to execute, I get "out of range"
error and the file close!

How can I make the macro name is independent of the file name; so it
doesn't keep referring to the old file name?

Regards,
Mike


--

Dave Peterson


All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com