Bonjour Steelson,
J'ai mis ce code, dans ma feuil1 :
Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
Private Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Private Function EnumWindowsProc&(ByVal hwnd&, ByVal lParam&)
Dim SLength&, Buffer As String, RetVal&
SLength = GetWindowTextLength(hwnd) + 1
If SLength > 1 Then
Buffer = Space(SLength)
RetVal = GetWindowText(hwnd, Buffer, SLength)
If CBool(IsWindowVisible(hwnd)) Then Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = Left(Buffer, SLength - 1)
End If
EnumWindowsProc = 1
End Function
Puis ceci dans un module :
Sub ListAppli()
Application.ScreenUpdating = False
Cells.ClearContents
EnumWindows AddressOf EnumWindowsProc, 0
Cells.Columns.AutoFit
Application.ScreenUpdating = True
End Sub
Sub appeler()
AppActivate Selection
End Sub
Mon bouton pour "ListAppli" me met en message d'erreur:
Le code contenu dans ce projet doit être mis à jour pour pouvoir être utilisé sur un systèmes 64 bits. Vérifiez et mettez à jour les instructions Declare, puis marquez-les avec l'attribut PtrSafe
Pour l'autre méthode,
j'ai essayé :
Sub fermernotepad()
AppActivate "C:\Users\seby\AppData\Roaming\Microsoft\Excel\macro.txt - Notepad++"
SendKeys "%{F4}"
End Sub
Du coup j'ai créé un blocnote nommé macro que j'ai enregistré sur ce chemin. Je l'ai laissé ouvert et j'ai cliqué sur le bouton excel mais là il me met cette ligne
AppActivate "C:\Users\seby\AppData\Roaming\Microsoft\Excel\macro.txt - Notepad++"
en surbrillance...