0

I want to open 1 or more Excel-workbooks programmatically. And when I open the workbook, you get a question: The workbook contains links to other data sources. And I don't want press "Don't update"

How can you leave this messagebox? So the functionality will not interrupted anymore. Updating is not needed.

enter image description here

mason
  • 31,774
  • 10
  • 77
  • 121
user1531040
  • 2,143
  • 6
  • 28
  • 48
  • You say you're opening the workbook programmatically. Are you using the Microsoft Office Interop libraries? If so, you should tag your question with that. – mason Dec 22 '14 at 16:54
  • If this is using Microsoft Interop, potential duplicate of: http://stackoverflow.com/questions/5575117/how-to-disable-popups-when-openning-in-office-interop – Steve Lillis Dec 22 '14 at 16:59

2 Answers2

2

try placing in the workbook Open event handler:

Application.AskToUpdateLinks = False
Sievajet
  • 3,443
  • 2
  • 18
  • 22
1

I don't think you can get around the dialogs with the excel interop libraries (the warnings are there for a reason). The way I've always done this in the past is to treat the Excel file like it's a database, and use the following:

OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFileName + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\"");

Then you can use the following to get information about the sheets:

DataTable lookupSheets = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

Then use the debugger to understand what is behind the lookupSheets variable and start writing queries like you would with any other database.

Note: You cannot use the richer elements of the interop libraries like formatting

Mr. B
  • 2,845
  • 1
  • 21
  • 31