Sub Ouvrir_Text_bloknote2()
Dim AppHandle As LongPtr
Dim fichier$
Dim notepadpath$
Dim N$, used As Boolean
If TaskPaneUsed Then MsgBox " le volet est deja utilisé" & vbCrLf & "Vous devez fermer le volet actuel": Exit Sub
fichier = Application.GetOpenFilename("pdf Files (*.txt;*.csv;*.bat;*.cmd), *.txt;*.csv;*.bat;*.cmd", 1, "ouvrir un fichier")
If fichier = "Faux" Then Exit Sub
'au cas ou windows ne serait pas installé sur "C" on prefere aller chercher le chemin de l'exe
notepadpath = CreateObject("Scripting.FileSystemObject").GetSpecialFolder(0).Drive '0 = WindowsFolder
notepadpath = notepadpath & "\Windows\System32\Notepad.exe"
Shell """" & notepadpath & """ """ & fichier & """", vbNormalFocus
N = Split(Mid(fichier, InStrRev(fichier, "\") + 1), ".")(0)
AppHandle = GetWinHandle("Notepad", N, 10) 'appel de ma fonction getwinhandle
If [D1] = "Vrai" Then SetWindowLong AppHandle, -16, &H16000000 'checkbox on vire la caption
docking AppHandle
Dim AppForm As LongPtr
If TaskPaneUsed Then MsgBox " le volet est deja utilisé" & vbCrLf & "Vous devez fermer le volet actuel": Exit Sub
Set usf = UserForm1
With usf
.Show 0
End With
AppForm = GetActiveWindow
If [D1] = "Vrai" Then SetWindowLong AppHandle, -16, &H16000000 'checkbox on vire la caption
SetParent AppHandle, AppForm
docking AppHandle
End Sub