Bonjour Staple,
Objectif atteint avec ce code :
Declare PtrSafe Sub ClientToScreen Lib "user32" _ (ByVal hwnd As Long, lpPoint As POINT)
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As tring, _ ByVal lpWindowName As String) As Long
Declare PtrSafe Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" ( ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _ ByVal lpsz2 As String) As Long
Declare PtrSafe Sub keybd_event Lib "user32.dll" _
(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Declare PtrSafe Sub mouse_event Lib "user32" _
(ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, _
ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Declare PtrSafe Function SetCursorPos Lib "user32" _
(ByVal x As Long, ByVal y As Long) As Long
Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Declare PtrSafe Function EmptyClipboard Lib "user32" () As Long
Declare PtrSafe Function CloseClipboard Lib "user32" () As Long
Const SW_NORMAL As Long = 1
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const KEYEVENTF_KEYUP = &H2
Const VK_CONTROL As Long = &H11
Const VK_C = 67
Const VK_V = 86
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type POINT
x As Long
y As Long
Private Sub CommandButton65_Click()
Dim DataObj As New MSForms.DataObject
Dim Mon_texte As String
Dim RetVal As Long
ClearClipboard 'on vide le presse-papier
'on ouvre l'explorateur Windows
RetVal = ShellExecute(0, "open", "explorer.exe", "C:\Users\xxxx\Documents\dossiers", 0, SW_NORMAL)
Sleep 1000
If RetVal = 2 Or RetVal = 3 Then
MsgBox "Chemin ou fichier non trouvé"
Exit Sub
End If
'on copie le texte de la cellule active dans le presse-papier
Mon_texte = Me.ComboBox2.Value (variable)
DataObj.SetText Mon_texte
DataObj.PutInClipboard
Sleep 500
'on se place dans la fenêtre de saisie y pour coller le contenu du presse-papier
SendKeys String:="{F3}", wait:=True
keybd_event VK_CONTROL, 0, 0, 0
keybd_event VK_V, 0, 0, 0
keybd_event VK_V, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_CONTROL, 0, 0, 0
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
Sleep 1000
SendKeys String:="{ENTER}", wait:=True
With Application
DoEvents
Application.SendKeys ("{NUMLOCK}"), True
End With
End Sub[/CODE]
Merci encore pour ton sens de l'orientation.