PDA

View Full Version : Create Copies of Workbook



fb7894
09-25-2008, 08:33 AM
I want to do the following:
-Open Workbook A
-Create 2 copies of Workbook A (I'll name them Workbook B & C).
-Modify Workbooks B & C slightly
-Save all 3 workbooks.

I'm running into trouble creating copies of workbook A. If I use the WB.SaveAs method, I can create Workbook B, but Workbook A is now closed.

Is there a way to create a copy of a workbook without losing the original workbook?

Thanks,

lucas
09-25-2008, 08:55 AM
Maybe savecopyas will work better. Try this, it seems to do what you require.


Sub savecopyas()
ActiveWorkbook.savecopyas "C:\TEMP\XXXX.XLS"
ActiveWorkbook.savecopyas "C:\TEMP\ooo.XLS"
End Sub

fb7894
09-25-2008, 10:59 AM
Thanks Lucas. SaveCopyAs creates a copy but that copy is not an open workbook. So if want to modify the workbook (which I do), I'm forced to open it. Seems like a waste. Seems like there should be a way to make a copy of a WB and have that WB stay open.

lucas
09-25-2008, 12:36 PM
If it's important you can open them after creating them:

Sub savecopyas()
ActiveWorkbook.savecopyas "C:\TEMP\XXXX.XLS"
ActiveWorkbook.savecopyas "C:\TEMP\ooo.XLS"
ChDir "C:\Temp"
Workbooks.Open Filename:="C:\Temp\XXXX.XLS"
Workbooks.Open Filename:="C:\Temp\ooo.XLS"
End Sub

fb7894
09-25-2008, 05:47 PM
Thanks Lucas. I take it there is no way to copy a workbook and leave it open then? When I work remotely, it can take up to 20 seconds or so to open a workbook. Some of my programs open 100s of workbooks. So saving a copy and then re-opening the copy could potentially cost me many minutes of run time. Seems like there should be a more efficient way.

Anyway, thanks for the helpl