Microsoft 365 Pb avec Windows

LUMBARDO

XLDnaute Nouveau
Bonjour,
J'ai un code qui fonctionnait bien jusqu'à hier où des modifications à Windows ont été apportées.
Il permet de faire une recherche dans un dossier à partir d'un Useform.

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:\Utilisateurs\x\Documents\dossiers", 0, SW_NORMAL)
Sleep 1000

If RetVal = 2 Or RetVal = 3 Then
MsgBox "Chemin ou fichier non trouvé"
Exit Sub
End If
If ComboBox2.Value = "" Then
MsgBox "Il n'y a pas de dossier sélectionné !", vbOKOnly + vbCritical, "Vas te coucher !"
Unload Me
irs1.Show
Exit Sub
End If
'on copie le texte de la cellule active dans le presse-papier

Mon_texte = Me.ComboBox2.Value
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

J'ai vérifié il met bien dans le presse papier le numéro mais après pour une raison inconnue il copie dans la barre de recherche le symbole Windows...

Quelqu'un a t-il rencontré ce cas ?
 

LUMBARDO

XLDnaute Nouveau
re
bonjour
ben si on a pas ton fichier on risque pas de savoir
sur quelle ligne est déclenchée l'erreur ?
Bonjour,
1675679016517.png
1675679083128.png



J'en profite pour vous féliciter pour les calendriers qui fonctionnent très bien 👍
 

LUMBARDO

XLDnaute Nouveau
Bonjour,
Avec ce code je vais jusqu'à "ouvrir" la barre de recherche windows 11 mais pour une raison inconnue il ne copie pas la valeur qui est le presse papier (qui est bien alimenté par le combobox).
Private Sub CommandButton66_Click()

Dim objclipboard As MSForms.DataObject
Dim WshShell As Object

Set objclipboard = New MSForms.DataObject
objclipboard.SetText Me.ComboBox2.Value
objclipboard.PutInClipboard
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "^{ESC}"
WshShell.SendKeys "^V"
End Sub
 

LUMBARDO

XLDnaute Nouveau
Voilà le code qui fonctionne pour moi (9 fois sur 10).

Private Sub CommandButton64_Click()

Dim objclipboard As MSForms.DataObject
Dim WshShell As Object

Set objclipboard = New MSForms.DataObject
objclipboard.SetText Me.ComboBox2.Value
objclipboard.PutInClipboard
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "^{ESC}"
WshShell.SendKeys "^e"
Application.wait (Now + TimeValue("0:00:01"))
WshShell.SendKeys "^V"
Application.wait (Now + TimeValue("0:00:02"))
WshShell.SendKeys "{ENTER}"

End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 175
Messages
2 085 952
Membres
103 058
dernier inscrit
florentLP