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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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.
 
Back
Top