View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Alan Alan is offline
external usenet poster
 
Posts: 188
Default How do I copy an entire worksheet to another instance of excel?

"Alan" wrote in message
...

Hi All,

I have a worksheet in once instance of excel (xlAppSource) that I

need
to programmatically copy to another instance of excel (xlAppDest).

I can copy it to a new workbook within xlAppSource, but I really

need
it in a different instance (since many application level settings

are
tied down in source, but the user can play to their heart's content

in
the destination instance).


Something like this:

I have:

xlAppSource.Workbooks("Main").Worksheet("Data")

I would like to copy that worksheet so that the copy is:

xlAppDest.Workbooks(1).Worksheet("Data")


The problem is that when I try to use the paste method I get an

error,
and if I use the PasteSpecial method I just get a picture of the
worksheet (which is only partial anyway).

I could do it cell by cell looping through the entire usedrange, but
that takes ages (we are talking about 30 columns by 6000 rows ~
180,000 cells) and the users would not regard that as a god

solution!


Is it possible to copy an entire worksheet across to another

instance?

Thanks,



Doh doh doh!

xlAppSource.Workbooks("Main").Worksheet("Data").Us edRange.Copy
xlAppDest.Workbooks(1).Worksheet("Data").Range("A1 ").Select
xlAppDest.Workbooks(1).Worksheet("Data").Paste

I was getting an error when I had this:

xlAppSource.Workbooks("Main").Worksheet("Data").Us edRange.Copy
xlAppDest.Workbooks(1).Worksheet("Data").Range("A1 ").Paste

and thought that it was because the destination was in a new instance.
Infact it was just my bad coding!

Thank you to all who contributed. I would still prefer not to have to
copy the cells, but it appears that that is not possible from what has
been posted.

Regards,

Alan.