Unless the macro is always going to run in the active workbook, then I think the most convenient would be to use a GetOpenFileName. Assuming that workbook that you want to copy to isn't already open.
Sub test()
Dim Nme
Nme = Application.GetOpenFilenam
''''select the work book that you want to copy the chart to copy to
Workbooks(Nme).Open
MsgBox (Nme)
End Sub
Otherwise, if the macro is stored in the activeworkbook, then just use:
Sub test2()
Dim Nme
Nme = ActiveWorkbook.Name
Workbooks(Nme).Select
End Sub
If you always know that the count order of the workbook, then you could use that number, like:
Workbook(1).activate
'''or whatever number it is...
I hope that helps...:)
Main Topics
Browse All Topics





by: saurabh726Posted on 2009-10-19 at 11:01:34ID: 25607469
Drezner7,
In your code wherever you see a...
Windows("091019.xls"). Activate
Th ats where you are selecting the workbook, Now if you want the code to workon any workbook, Then either remove that line or replace with your workbook name and that will do what you are looking for...
Saurabh...