Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy worksheets in excel automation app using VC7

Hello,

I'm doing this automation application that involves copying a sheet from a
specific workbook to another workbook.
I have this code:


CWorkbook WinBook = books.Open(szWorkbook,covOptional, covOptional,
covOptional, covOptional,

covOptional, covOptional, covOptional, covOptional,

covOptional, covOptional, covOptional, covOptional, covOptional, covOptional

);

CWorkbook BRBook = books.Open(szWorkbook2,covOptional, covOptional,
covOptional, covOptional,

covOptional, covOptional, covOptional, covOptional,

covOptional, covOptional, covOptional, covOptional, covOptional, covOptional

);

WBSheets = WinBook.get_Sheets();

BRSheets = BRBook.get_Sheets();

WBsheet = WBSheets.get_Item(COleVariant((short)3));

BRSheet = BRSheets.get_Item(COleVariant((short)1));

CString s1 = CString("[");

s1+= CString(WinBook.get_Name());

s1+= CString("]");

s1+= CString(WBsheet.get_Name());

BRSheet.Copy(covOptional,COleVariant(s1));

...



So this piece of code opens two workbooks: one source (BRBook) and one
destination(WinBook). Takes the sheet to be copied: BRSheet and builds a
string that descibes the sheet after wicht the sourche sheet should be put.

But this code gives me a runtime error message saying the copy method of the
sheets object failed. What am i doing wrong? Thank you very mucht,



Yannick from belgium


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Automation : numbers Copy/Paste issue from VB6 [email protected] Excel Programming 6 July 7th 06 09:18 AM
Copy Excel worksheets TedDSC Excel Discussion (Misc queries) 2 December 27th 04 09:59 PM
Copy generates an automation error. Richard[_24_] Excel Programming 1 January 16th 04 12:37 PM
Compiling different worksheets, via automation. Tom Ogilvy Excel Programming 1 September 25th 03 08:10 PM
Excel Worksheets.Copy in VBS??? Mark[_13_] Excel Programming 1 July 31st 03 05:40 PM


All times are GMT +1. The time now is 06:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"