Bonjour,
Je cherche a récupérer certaines données d'un classeur pour les insérer dans un autre. Je dois tout d'abord effectuer une requête de tri dans le classeur source avant d'en récupérer les données. Cependant je n'arrive pas a l'activer.
Voici mon code, situé dans le classeur destination :
Dans la Msgbox s'affiche le nom du fichier destination (ThisWorkbook) alors que je souhaiterais obtenir le nom du fichier source (wbExcel).
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 Private Sub STL() Dim appExcel As Excel.Application Dim wbExcel As Excel.Workbook Dim wsExcel As Excel.Worksheet Dim Path As String 'Dim RSE As Integer 'Dernière ligne du fichier source 'Dim CSE As Integer 'Dernière colonne du fichier source Path = Application.GetOpenFilename("Nom fichier,*.xls") Set appExcel = CreateObject("Excel.Application") Set wbExcel = appExcel.Workbooks.Open(Path) Set wsExcel = wbExcel.Worksheets(1) 'RSE = wsExcel.Range("A65536").End(xlUp).Row 'CSE = wsExcel.Range("IV1").End(xlToLeft).Column wbExcel.Activate '=> Probleme : wbExcel ne s'active pas !!!!!! MsgBox (ActiveWorkbook.Name) 'ActiveWorkbook.Cells(RSE, CSE).Select 'Range(Selection, "A1").Select 'puis requête de tri '(...) wbExcel.Close False Set wsExcel = Nothing Set wbExcel = Nothing appExcel.Quit Set appExcel = Nothing End Sub
Merci de m'avoir lu et merci pour votre aide,
Sébastien
Partager