Bonjour
J'ai un Userform dont le code est le suivant:
et j'ai ma sub nommée ImportDonnées contenue dans un module dont le code est le suivant:
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 Private Sub CommandButton1_Click() Dim FichierChoisi As String FichierChoisi = Application.GetOpenFilename Dim j As Integer Dim con As ADODB.Connection With con .Provider = "Microsoft.Jet.OLEDB.4.0" .ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & FichierChoisi & _ ";Extended Properties=""Excel 12.0;HDR=YES;""" .Open End With Call ImportDonnées End Sub
le problème c'est que ma macro s'arrête à ce niveau
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 Sub ImportDonnées() Dim wbContrepartie As Workbook Dim n3 As Integer Set wbContrepartie = Workbooks.Open(FichierChoisi) Sheets(Feuil1).Select n3 = Workbooks("TP8").Sheets.Count Sheets(Feuil1).Copy After:=Workbooks("TP8.xlsm").Sheets(n3) wbContrepartie.Close Set wbContrepartie = Nothing Workbooks("TP8").Sheets(Feuil1).Select End Sub
en me disant que ma variable FichierChoisi n'est pas définie.
Code : Sélectionner tout - Visualiser dans une fenêtre à part Set wbContrepartie = Workbooks.Open(FichierChoisi)
Je ne sais pas comment la déclarer dans ma sub. Merci de m'apporter votre aide.
Partager