Copy and pasting files with macros

K

Kevin

I have written some macros in an excel file and assigned these macros to
custom toolbar buttons. This works great until I copy and paste the file and
open the new copy. The macro link for the buttons points to the original
macro. Is there anyway to set this up so that I don't have to re-assign the
macro every time and look at the open file instead.
 
N

Nick Hodge

Kevin

Difficult to tell without the code, but if it has an actual reference in the
code to the workbook name, e.g..

Workbooks("OriginalBook")...........

Then you would do better to use something like the ThisWorkbook object.
This always points to the workbook containing the code.

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
[email protected]
 
Top