Problem opening Excel workbook using Excel Interop

B

Blutonium

Hi everyone,

I'm writing a C# forms application to open an existing Excel workbook using
the Excel Interop. Everything works fine. I can read and write fine. I do not
save the workbook until the user close the C# application. The problem
happens when my program is running and the user accidentally opens the same
workbook with Excel. I get the error:

Exception from HRESULT: 0x800401A8

at this line

Range excelRange = worksheet.UsedRange;

Is there a way to lock the workbook and not allow the user to open it with
Excel when my program is running?

Thanks
 
I

IndyN East

Excel xL = new Excel.Application();
xL.Interactive = false; //this line must be inserted right after the Excel object has been instantiated.




Blutonium wrote:

Problem opening Excel workbook using Excel Interop
06-May-10

Hi everyone,

I am writing a C# forms application to open an existing Excel workbook using
the Excel Interop. Everything works fine. I can read and write fine. I do not
save the workbook until the user close the C# application. The problem
happens when my program is running and the user accidentally opens the same
workbook with Excel. I get the error:

Exception from HRESULT: 0x800401A8

at this line

Range excelRange = worksheet.UsedRange;

Is there a way to lock the workbook and not allow the user to open it with
Excel when my program is running?

Thanks

Previous Posts In This Thread:

Problem opening Excel workbook using Excel Interop
Hi everyone,

I am writing a C# forms application to open an existing Excel workbook using
the Excel Interop. Everything works fine. I can read and write fine. I do not
save the workbook until the user close the C# application. The problem
happens when my program is running and the user accidentally opens the same
workbook with Excel. I get the error:

Exception from HRESULT: 0x800401A8

at this line

Range excelRange = worksheet.UsedRange;

Is there a way to lock the workbook and not allow the user to open it with
Excel when my program is running?

Thanks


Submitted via EggHeadCafe - Software Developer Portal of Choice
Task Parallelism in C# 4.0 with System.Threading.Tasks
http://www.eggheadcafe.com/tutorial...f8b-50cfd1a51577/task-parallelism-in-c-4.aspx
 

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