renaming files with macros


Posted by Rachel on October 12, 2001 12:31 PM

I have created a macro to print several different portions of my worksheet in a certain sequence. However, each week I need to save my file as a different name before printing. Then when I run the macro to print the information, it opens the original file and prints that one. How do I get the macro to reference the open file and not the specific one?

Posted by Todd on October 12, 2001 1:05 PM

You should be able to reference the current work book as the active one. Like, ActiveWorkbook.Range("b1:c50").Printout
something like that...

Posted by Rachel Bonson on October 12, 2001 1:18 PM

Thanks for the help. But can you be more specific. I am really new at macros. For example, what the line says currently is...

Application.Run "'sales.xls'!ADMIN"

where ADMIN is the name of the macro that is running within the macro.

Thanks.

Posted by Todd on October 12, 2001 1:38 PM

If the macro is in the same workbook, then just call it directly, i.e. Call ADMIN (if in a module) or Call Sheet1.ADMIN (if on a sheet).
If in another workbook, I'm not sure what to do. Maybe you could put the macro in the same workbook. If that's not possible, maybe you could have the user input the new file name in an inputbox, set the input equal to a variable, and work that into your command.



Posted by Tommy Lawton on October 12, 2001 3:16 PM


You will need to revise your code in the ADMIN macro that is in Sales.xls so that it works on the Active Workbook and not just on Sales.xls