LUSTRUCRU
Messages postés91Date d'inscriptionmardi 8 avril 2003StatutMembreDernière intervention15 mars 2013 11 janv. 2009 à 17:19
Voila qui devrait t'aider un peu
Private Sub CommandButton1_Click()
Call TestGetValue
End Sub
Private Function GetValue(Path, File, Sheet, Ref)
'Récupération d'une valeur dans un fichier fermé
Dim Arg As String
'Crée l'argument de la fonction XL4
Arg = "'" & Path & "[" & File & "]" & Sheet & "'!" & Range(Ref) _
.Range("A1").Address(, , xlR1C1) '
'Exécute la macro XLM
GetValue = ExecuteExcel4Macro(Arg) '<<<< ligne à rajouter ICI
End Function
Sub TestGetValue()
'Récupérer dans la feuille active 1000 lignes et 4 colonnes d'un fichier fermé
Dim P As String, f As String, S As String
Dim A As String
Dim C As Long, R As Long, I As Long
P = "C:\Mes Documents"
f = "MonFichier.xls"
S = "Feuil1"
'Vérifie l'existence du fichier, ajoute les séparateurs manquants
If (Right(P, 1) <> "") Then P = P & ""
If (Dir(P & f) <> "") Then
Range("A1").CurrentRegion.ClearContents
I = 0
Application.ScreenUpdating = False
For R = 1 To 2000
For C = 1 To 7
I = I + 1
Cells(R, C) = GetValue(P, f, S, Cells(R, C).Address)
Next C
Next R
Application.ScreenUpdating = True
End If
End Sub