Je n'arrive pas à ouvrir un fichier excel, pourtant j'ai bien l'impression de faire ce qu'il faut :
J'ai fait : Imports Microsoft.Office.Interop
Voici ma sub qui pose problème :
Une exception est levée :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click Dim xlsapp As New Excel.Application Dim book As Excel.Workbook Try book = xlsapp.Workbooks.Open("monfichierexcel.xls") Catch ex As Exception MessageBox.Show(ex.ToString()) End Try End Sub
System.NullReferenceException La référence d'objet n'est pas définie à une instance d'un objet. at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad) at WindowsApplication3.Form12.Button6_Click(Object sender, EventArgs e) in CDocuments and Settingsm.huinMes documentsVisual Studio ProjectsWindowsApplication3Form12.vbline 640
Aidez moi svp, je ne sais pas quoi faire !
Merci.
Partager