What are parameters for Workbooks.Open() Using Interop.Excel?

G

Guest

Hello.

I am using Microsoft.Office.Interop.Excel in a C# .NET project. I want to
open an Excel application with a specific file name.

I am currently opening it with this code:

oXL.Workbooks.Open(src, Type.Missing, true, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

However, if I happen to open a file created with an older version of Excel,
I get a message prompt asking me if I want to save the changes to the file.
"Microsoft Office Excel recalculates formulas when opening files last saved
by an earlier version of Excel".

Since I am using automation, I don't want command prompts to appear during
my program.

I was hoping that the arguments to Open() would take care of that. However,
I have done a lot of searching on the topic and have found no documentation
about what each of the parameters mean.

From that, I have two questions for this newsgroup:

1) Can someone explain what each of those 15 or so parameters for Open()
mean or can point to a URL that identifies those?

2) What is the best way to ensure no prompts pop up when using automation in
C# .NET with Excel?

Thanks in advance.

-Sarah
 
A

Arne Janning

Hi Sarah,

Sarah said:
I am using Microsoft.Office.Interop.Excel in a C# .NET project. I want to
open an Excel application with a specific file name.

I am currently opening it with this code:

oXL.Workbooks.Open(src, Type.Missing, true, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

However, if I happen to open a file created with an older version of
Excel,
I get a message prompt asking me if I want to save the changes to the
file.
"Microsoft Office Excel recalculates formulas when opening files last
saved
by an earlier version of Excel".

Since I am using automation, I don't want command prompts to appear during
my program.

I was hoping that the arguments to Open() would take care of that.
However,
I have done a lot of searching on the topic and have found no
documentation
about what each of the parameters mean.

From that, I have two questions for this newsgroup:

1) Can someone explain what each of those 15 or so parameters for Open()
mean or can point to a URL that identifies those?

The Excel 11 Object Model is located here:
http://msdn.microsoft.com/library/en-us/vbaxl11/html/xltocOMMap.asp

A deep discussion of every single parameter is located here:
http://msdn.microsoft.com/library/en-us/vbaxl11/html/xlmthOpen1.asp
(click on "Open method as it applies to the Workbooks object")

Good and useful collection of How-to's:
http://msdn.microsoft.com/library/en-us/dv_wrcore/html/wroriautomatingexcelusingexcelobjectmodel.asp
2) What is the best way to ensure no prompts pop up when using automation
in
C# .NET with Excel?

Application.DisplayAlerts = false
should solve your problem.

Cheers

Arne Janning
 

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