Copy Excel Worksheet
Copy Excel Worksheet
Copy Excel Worksheet
Copy Excel Worksheet
Copy Excel Worksheet
Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet
Copy Excel Worksheet Copy Excel Worksheet
Copy Excel Worksheet
Go Back  Xtreme Visual Basic Talk > > > Copy Excel Worksheet


Reply
 
Thread Tools Display Modes
  #1  
Old 02-16-2004, 05:31 AM
brtp brtp is offline
Newcomer
 
Join Date: Feb 2004
Posts: 3
Unhappy Copy Excel Worksheet


Hi,

I want to copy an excel worksheet from a workbook to another, but i don't know how.
Pls. Help! VB.

Thanks
Reply With Quote
  #2  
Old 02-16-2004, 05:57 AM
herilane's Avatar
herilaneCopy Excel Worksheet herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

VB6, VBA or VB.Net?
Reply With Quote
  #3  
Old 02-16-2004, 06:03 AM
brtp brtp is offline
Newcomer
 
Join Date: Feb 2004
Posts: 3
Default

Quote:
Originally Posted by herilane
VB6, VBA or VB.Net?


VB.NET
Reply With Quote
  #4  
Old 02-16-2004, 08:11 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

The basic commands would be, roughly,

Code:
oExcel.Workbooks([i]WorkbookName[/i]).Worksheets([i]SheetName[/i]).Cells.Copy oExcel.Workbooks([i]MyOtherWorkbookName[/i]).Worksheets([i]MyOtherSheetName[/i]).Cells.Paste
That's how it would be in VB 6.0 or in VBA anway. However, converting this to .Net, is a bit of work... I suggest you have a read at the tutorial here VB.Net Office Integration Tutorial and then take a shot at it yourself...

If/when you get stuck, come back and ask!

However, if it is at all feasible for you to use VB 6.0 or VBA for this, I would highly recommend it. As the tutorial will show, the amount of work required for Automating Excel via VB.Net is quite a bit and it can get a little tricky... It's ok, once you have it down, but it will always be a lot more work than would be required to do the same in VB6 or VBA.

-- Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
  #5  
Old 02-17-2004, 04:28 AM
brtp brtp is offline
Newcomer
 
Join Date: Feb 2004
Posts: 3
Smile Thanks

Thanks Mike_R this was useful to me.

Paul.
Reply With Quote
  #6  
Old 02-18-2004, 10:21 AM
lichuk lichuk is offline
Newcomer
 
Join Date: Feb 2004
Location: UK
Posts: 8
Default

Wouldn't the WorkSheet.Copy method be more suitable ?
Reply With Quote
  #7  
Old 02-18-2004, 10:43 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

Well, that's what I was showing, actually.
Code:
Worksheet.Cells.Copy
I was just using the term "Cells" to be a tad more explicit/clear.

But, yes, one can simply use Worksheet.Copy() making use of the 'Before' or 'After' parameter. Whatever one finds clearer for them, I guess....

,
Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
  #8  
Old 02-18-2004, 11:39 AM
lichuk lichuk is offline
Newcomer
 
Join Date: Feb 2004
Location: UK
Posts: 8
Default

Code:
SouceWorksheet.Copy after:=DestinationWorksheet ' or SouceWorksheet.Copy beforer:=DestinationWorksheet

I guess it depends if you just want to copy some cells, or you want to copy a worksheet (and anything associated with it) :-)
Reply With Quote
  #9  
Old 02-18-2004, 11:46 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

Ok, agreed. If you want the Graphics, Charts, Buttons and all to be copied as well, then you have no choice.

I tend to think in terms of Cells and Cell values, Formulas and Foramtting only, but you are right, this was a poor assumption on my part.

Good pickup, thanks ,
Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy data from an opened textfile to a excel worksheet ThoJToy Excel 4 06-10-2003 06:06 AM
Populating an Excel Worksheet embedded in an Access Report with data mavalon Word, PowerPoint, Outlook, and Other Office Products 7 04-23-2003 01:31 PM
word to excel: cannot copy variables > 1k galenjm Word, PowerPoint, Outlook, and Other Office Products 3 02-04-2003 10:29 PM
Excel VBA: Copy to Cell A1 - Invalid Qualifier Error izzyq Word, PowerPoint, Outlook, and Other Office Products 1 03-26-2002 03:42 PM
create a Excel application or use a existing copy MIsnow Word, PowerPoint, Outlook, and Other Office Products 1 01-11-2002 08:38 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Copy Excel Worksheet
Copy Excel Worksheet
Copy Excel Worksheet Copy Excel Worksheet
Copy Excel Worksheet
Copy Excel Worksheet
Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet Copy Excel Worksheet
Copy Excel Worksheet
Copy Excel Worksheet
 
Copy Excel Worksheet
Copy Excel Worksheet
 
-->