Move Worksheet from one Workbool to another - fails on Excel 2007

G

Guest

A macro I used on Excel 2003 has stopped working now I am on Excel 2007.
I open a text files as a workbook then copy that sheet (the only sheet) into
another workbook which has been opened from a template, this way I am
combining the raw data i need in a text file with the formatting/macros I
need in the template workbook.
Here is the code

Dim xl As Excel.Application
Dim wbkCode As Excel.Workbook
Dim wbkTemp As Excel.Workbook



Set wbkTemp = xl.Workbooks.Open(filename:=strTempFullPath)
Set wbkCode = xl.Workbooks.Open(filename:=strWorkBookName)
wbkTemp.Workheets(1).Move before:=wbkCode.Worksheets(1)

the third line gives no errors, but adds no work sheets to wbkCode.
I can't use a range copy and paste as the text file can be extremely large,
right up to the limits of Excel's capacity, so the worksheet has to be moved
as an object as above. Any help greatly appreciated!
 
C

Chip Pearson

Could a moderator change the spelling in the thread title for Workbook?

There is no moderator.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top