Open an existing Excel-workbook from a C#-Appllication

2

24frank

Hello,
i'm searching for a method to open an existing Excel-workbook from my
C#-Application.
For open a new workbook I use this Code:
//Start Excel and get Application object.
oXL = new Excel.Application();
oXL.Visible = true;
//Get a new workbook.
oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value ));
oSheet = (Excel._Worksheet)oWB.ActiveSheet;
....

Now I need an example, how I can open an existing workbook.

I hope someone can help me.
Thanks Frank.
 
H

Harlan Grove

24frank said:
i'm searching for a method to open an existing Excel-workbook from my
C#-Application.
For open a new workbook I use this Code:
//Start Excel and get Application object.
oXL = new Excel.Application();
oXL.Visible = true;
//Get a new workbook.
oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value ));
oSheet = (Excel._Worksheet)oWB.ActiveSheet;
...

Now I need an example, how I can open an existing workbook.

Presumably you have some 32-bit version of Excel on your system or you
couldn't test your code. Unless your IT staff is perverse, you should have
online help for Excel/VBA and Excel's object model. Try running Excel, and
once it's running, press [Alt]+[F11] to run the Visual Basic Editor (VBE),
then use VBE's Help menu to access online help for Excel's object model.

You want the Open method of the Workbooks collection class.
 

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