Click here to Skip to main content
Licence CPOL
First Posted 26 Mar 2009
Views 10,952
Bookmarked 10 times

Opening and Navigating Excel with C# - Removing dialogs

By | 26 Mar 2009 | Article
Remove dialogs

Introduction

Take a look at the article below first. The only thing I'm adding here is how to remove dialogs... since I couldn't find that anywhere online.

Code

Error: The problem is that every time I run it, a message box comes up saying: "'example.xls' is being modified by johndoe. Open as read-only?"

Solution:

Before opening the Excel file, run this code:

excelApp.DisplayAlerts = false;

So, the entire code would look like this:

Microsoft.Office.Interop.Excel.Workbook workbook;

Microsoft.Office.Interop.Excel.ApplicationClass excelApp = 
          new Microsoft.Office.Interop.Excel.ApplicationClass();

excelApp.DisplayAlerts = false;

workbook = excelApp.Workbooks.Open(   
    filename,
    ExcelLib.XlUpdateLinks.xlUpdateLinksAlways, 
    ReadOnly, 5, Type.Missing, Type.Missing, true,
    ExcelLib.XlPlatform.xlWindows, Type.Missing, 
    true, false, Type.Missing, false, false,
    ExcelLib.XlCorruptLoad.xlNormalLoad 
);

And that's all I wanted to add. (Note, the linked article isn't allowing me to post, otherwise I'd have thrown a message up there on it.)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

ColinBashBash

Software Developer

United States United States

Member

likes boardgames, computer games, and enjoys his .net programming job.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralReason you couldn't post a message to the linked article PinmemberKent K8:09 31 Mar '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 26 Mar 2009
Article Copyright 2009 by ColinBashBash
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid