How to copy workbook?
You say that you want "to make the opened document identic to the one I am
copying from".
If so then, create a copy of the file first, then open the copy:
name oldfile as newfile
workbooks.open newfile
However, if you really mean that you want to import all the sheets from the
oldfile into the newfile :
Dim SourceWB as workbook
Dim DestinationWB as workbook
dim WS as worksheet
set SourceWb =workbooks.open(oldfile)
set DestinationWb =workbooks.open(newfile)
for each ws in sourcewb.worksheets
WS.Copy After:=DestinationWb.Sheets(DestinationWb.sheets.c ount)
next
NickHK
"LF" wrote in message
...
Hello,
I have a workbook open and I want to populate it with the content of
another
xls file. How can I do that. I wan everything transferred: values,
formulas,
embedded object, formatting, everyhting. I figured that I coould do a
sheet
by sheet copy/paste (of course, enumerating the sheets and chart sheets in
the source document, recreating them in the destination document and then
doing the copy), but I am having a hard time copying over anything else
than
values. Also, where are the macros stored? In each sheet or are they
workbook specific? Is there anything else to copy over to make the opened
document identic to the one I am copying from?
Because the destination workbook is already open, I cannot do a SaveCopyAs
on the source workbook and then open that. I need to work with the one
that
is already opened.
Any help or guidance is greately appreciated, thank you.
Regards,
Levente
|