[Last Call] Learn how to a build a cloud-first strategyRegister Now


C# - how do I copy Excel Worksheet from one Workbook to another?

Posted on 2010-01-08
Medium Priority
Last Modified: 2013-12-17
Hi all-

Does anyone have C# code that copies an Excel worksheet from one workbook to another?  I'm using Office 2003 and Visual Studio 2005.  I have VSTO 2005 SE installed and am interested in using the Microsoft.Office.Tools.Excel object instead of the convoluted Excel Interop object.  I've been trying to get some VBA examples that I see on the 'net to work (obviously not using VSTO), but can't get that to work, nor anything I try with VSTO.

Thanks much!
Question by:DaveScan1
  • 2
LVL 36

Expert Comment

by:Miguel Oz
ID: 26214354

This code is VB.net 2008, but it will work for you as the code uses the same method signatures(Office 2003/2007 are the same in this area, just make sure to include the appropiate reference Microsoft.Office.Tools.Excel (11))

Translate this code to C# is very easy, I can do it if you like
LVL 36

Accepted Solution

Miguel Oz earned 1000 total points
ID: 26575405
The comment is self explanatory and provide the correct answer.
The C# code translation of my answer is available here:


Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question