Function GetWinHandle(Optional classe = "*", Optional Texte = "*", Optional sec As Long = 1)
Dim tim
tim = Timer
Do While Timer - tim < sec
hwnd = FindWindow(vbNullString, vbNullString) 'on commence avec la première fille du desktop
DoEvents
Do While hwnd <> 0
DoEvents
If IsWindow(hwnd) Then
'If IsWindowVisible(hwnd) Then
Dim clN$: clN = Space$(256): GetClassName hwnd, clN, 256
Dim txtx$: txtx = Space$(512): GetWindowText hwnd, txtx, 512
If clN Like classe & "*" Then
If txtx Like "*" & Texte & "*" Then
Debug.Print "handle : " & hwnd & vbCrLf; "titre : " & txtx & vbCrLf & "classe : " & clN
GetWinHandle = hwnd: Exit Function
End If
End If
'End If
End If
hwnd = GetWindow(hwnd, 2) 'on passe a la suivante
Loop
Loop
End Function
Sub testPDF_Xchange()
Dim appHandle As LongPtr
Dim Hnewparent As LongPtr
Dim He7 As LongPtr
Dim fichier$
fichier = "J:\vba excel\base 64 vba .pdf"
ShellExecute 0, "open", fichier, "", "", 1 ' SW_SHOWNORMAL
n = Split(Mid(fichier, InStrRev(fichier, "\") + 1), ".")(0)
Debug.Print "fichier : "; fichier
appHandle = GetWinHandle("DSUI:PDFXCViewer", n, 10)
exit sub 'on arrete ici tu n'a pas le reste de mes fonctions
t = AllPartExcelWindowList
For i = 2 To UBound(t)
If t(i, 2) = "XLDESK" Then Hnewparent = CLngPtr(t(i, 1)): Large = t(i, 7): haut = t(i, 8)
If t(i, 2) = "EXCEL7" Then He7 = CLngPtr(t(i, 1))
Next
SetWindowPos He7, 0, 0, 0, Large / 2, haut, 0
SetParent appHandle, Hnewparent
SetWindowPos appHandle, 0, Large / 2, 0, Large / 2, haut, 0
End Sub