Bonjour,
je réalise un export excel, j'ai donc importé la librairie microsoft excel 11 dans les references de mon projet, mais VS.NET 2002 ne me reconnait pas mes objets excel (il me souligne les mots excel en disant 'type excel non défini', voici mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
Dim xlApp As excel.Application
            Try
                xlApp = GetObject(, "excel.application")
            Catch
                xlApp = New Excel.Application
            Finally
                xlApp.Visible = False
            End Try
 
            Dim xsSoldesComptes5 As Excel.Worksheet = xlApp.Workbooks.Add.ActiveSheet
 
            Try
                With xsSoldesComptes5.QueryTables.Add(Connection:= _
                "ODBC;DRIVER=SQL Server;SERVER=KAA;Integrated Security=SSPI;" & _
                "APP=Microsoft® Query;DATABASE=Magellan;Trusted_Connection=Yes" _
                , Destination:=xsSoldesComptes5.Range("A1"))
 
                    .CommandText = "select * from lmsroute where period = " & cbxPeriod.Text
 
                    .Name = "SoldesComptes5"
                    .FieldNames = True
                    .RowNumbers = True
                    .FillAdjacentFormulas = False
                    .PreserveFormatting = True
                    .RefreshOnFileOpen = False
                    .BackgroundQuery = True
                    .RefreshStyle = Excel.XlCellInsertionMode.xlOverwriteCells
                    .SavePassword = False
                    .SaveData = False
                    .AdjustColumnWidth = True
                    .RefreshPeriod = 0
                    .PreserveColumnInfo = True
                    .Refresh(BackgroundQuery:=False)
                End With
 
                xlApp.Visible = True
Mon code est ok, je l'utilise dans une autre application. Alors qu'est ce que j'ai oublié ????

Merci !