Empêche le message pop d'Excel dans le code VB

J'ai un problème avec la boîte de message "Fichier maintenant disponible" ouverte depuis Excel lorsque j'impose un file à mon programme.

http://oi50.tinypic.com/23wajt.jpg

Private Function XLSSelect_Click(strFileName As Ssortingng) As DataTable Dim connectionSsortingngTemplate As Ssortingng = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source={0};" + "Extended Properties=""Excel 12.0;HDR=Yes;IMEX=1""" Dim connectionSsortingng As Ssortingng = Ssortingng.Format(connectionSsortingngTemplate, strFileName) Try Dim sqlSelect As Ssortingng = "SELECT * FROM [" & GetExcelSheetNames(strFileName)(0) & "];" ' Load the Excel worksheet into a DataTable Dim workbook As DataSet = New DataSet() Dim excelAdapter As System.Data.Common.DataAdapter = New System.Data.OleDb.OleDbDataAdapter(sqlSelect, connectionSsortingng) excelAdapter.Fill(workbook) For i As Integer = 0 To workbook.Tables(0).Columns.Count - 1 workbook.Tables(0).Columns(i).ColumnName = workbook.Tables(0).Columns(i).ColumnName.ToSsortingng.Trim.Replace(" ", "") Next Return workbook.Tables(0).Copy Catch Throw New Exception("Error reading from Excel Spreadsheet. Are you sure this file isn't currently open in Excel, and that it has been saved as a .xls through Excel at least once?") End Try Return Nothing End Function Private Shared Function GetExcelSheetNames(excelFile As Ssortingng) As [Ssortingng]() Dim objConn As OleDbConnection = Nothing Dim dt As System.Data.DataTable = Nothing Try Dim connSsortingng As [Ssortingng] = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & excelFile & ";Extended Properties=Excel 12.0;" ' Create connection object by using the preceding connection ssortingng. objConn = New OleDbConnection(connSsortingng) ' Open connection with the database. objConn.Open() ' Get the data table containg the schema guid. dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing) If dt Is Nothing Then Return Nothing End If Dim excelSheets As [Ssortingng]() = New [Ssortingng](dt.Rows.Count - 1) {} Dim i As Integer = 0 'Add the sheet name to the ssortingng array. For Each row As DataRow In dt.Rows excelSheets(i) = row("TABLE_NAME").ToSsortingng() i += 1 Next Return excelSheets Catch ex As Exception Return Nothing Finally ' Clean up. If objConn IsNot Nothing Then objConn.Close() objConn.Dispose() End If If dt IsNot Nothing Then dt.Dispose() End If End Try End Function 

Quelqu'un sait-il comment désactiver cela?

 Dim appExcel As Excel.Application Set appExcel = New Excel.Application appExcel.Workbooks.Open "e:\development\test.xls", 0 ' Do your thing here... appExcel.DisplayAlerts = False ' Surpress save dialog box. appExcel.Quit ' Quit without saving. you can change as you want Set appExcel = Nothing 

dans votre code

 Try Dim connSsortingng As [Ssortingng] = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & excelFile & ";Extended Properties=Excel 12.0;" ' Create connection object by using the preceding connection ssortingng. objConn = New OleDbConnection(connSsortingng) ' Open connection with the database. objConn.Open() 

appExcel.DisplayAlerts = False 'essayez ici!

  ' Get the data table containg the schema guid. dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing) 

Sources: http://www.xtremevbtalk.com/showthread.php?t=16007