index > Visual Studio Tools for Office > Import worksheet into open workbook

Import worksheet into open workbook

Hi,

I want to open an already existing workbook and import one of its sheets into a different already running workbook (I need to remap the data from one worksheet into a set of others). But when I open the *.xls file using the Workbooks.Open() method I get a remoting proxy to a different instance of excel. Is their a way to open the workbook in the already running instance, so that I can just grab the worksheet I want and deal with it. Without having to go through all of the remoting issues.

Thanks,

blair

Blair

Hi,

Ok I figured out how to do this but it really seems to be a hack, code below:

Excel.Workbook externalWorkbook = this.Application.Workbooks.Open(aFinder.FileName, 0, true, missing, missing, missing, true, missing, missing, missing, missing, missing, missing, missing, missing);

Excel.Sheets sheets = externalWorkbook.Sheets;

Excel.Worksheet aSheet = sheets.get_Item(1) as Excel.Worksheet;

aSheet.Copy(Globals.Sheet1.InnerObject, missing);

externalWorkbook.Close(missing, missing, missing);

Now why can't I just open it up and say merge into this workbook I really do not know. Oh well.

blair

Blair
reply 2

You can use google to search for other answers

 

More Articles

• Outlook Add-In Permissions
• Cannot Install VSTO 2005
• Help on exporting data from C# 2005 to an excel worksheet
• Assembly Reference Error
• Trouble saving combo box values back an SQL table
• Intellisense not showing Enumerator List If ParamArray is used
• SwitchView Infopath 2007 OM
• ListObject - ListColumn Caption
• Programmtically show / hide xml tags in the document
• Integration in an existing project
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• _ComObject specified cast exception call
• How to create new workseet from VSTO Exc
• Create an Excel Workbook/Worksheet progr
• Word, copying parts... -- beginner
• Task Pane controls
• VSTO SE, Vista RC2, Caspol, Oh My
• Shape.Hyperlink becomes protected in Off
• Assembly Link Location Property
• Calendar Date Range
• Implement similar behavior as http:// ad
• VSTO 2005 SE Deployment Problem
• Create a store and assign it a name (Out
• Open a new local mail and insert attachm
• Hosting a web page in Action Pane (MS Wo
• Problem when Publishing VSTO office 2007

Hot Articles

• WinWord instance not released from withi
• VSTO Properties Settings are the same as
• How is that called ? And how can I acces
• Is it possible? excel named ranges.... s
• working with different office and word o
• Using user properties in Find method
• VSTO Excel designer problem (Visual Stud
• VSTO2005-Word. Only want the code-behind
• Normal.dot changed when opening word....
• How to copy the sheet on excel developme
• word xml layout
• excel bugs
• VSTO Excel: Unable to read a range into
• InfoPathNamespace screwed...
• printing workbooks

Recommend Articles

• How to determine if my datatable is cach
• I cannot find a well documented API of V
• Need Help for Command Bar Button.
• batch conversion of excel files
• Internet Explorer causes vsto worksheets
• VSTO Word Document Code Not Running
• Please help me...
• Can't read app.config file
• Excel Addin CommandBarButton Click event
• Office automation - getting a built-in c
• KeyBindings in Word?
• cell formatting
• Comments color in Word
• Access Add-In from the OUTSIDE...
• Error on Visual Studio Tools for Office