Hallo Wissende,
in Excel 2000-Vba und in VB 5.0 passiert das gleiche Phänomen.
In beiden starte ich mit F1 jeweils die Hilfe.
Der nachstehende Code funktioniert in Vba und VB5.0. Man muß nur hier das Richtige auskommentieren:
List1.AddItem Task_name(index)
'Cells(index + 1, 1) = Task_name(index)
Für VB braucht man in der Form einen CommandButton und eine Listbox.
Der Code listet die Titel aller gefundenen Fenster auf.
Leider ist der Titel des jeweiligen Hilfefensters nicht darunter
Wie also komme ich per Code Zugriff auf das Hilfefester?
Sinn des Ganzen soll sein, das Hilfefenster (von Excel2007) wird bei Start mit der Einstellung „Immer im Vordergrund“ o.ä. geöffnet. Per Klick auf ein Symbol in der Symbolleiste kann man das zwar deaktivieren aber nicht dauerhaft, aber wie mache ich das mit VB/VBA ?
Danke ^ Gruß
Reinhard
Option Explicit
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Const GW\_HWNDFIRST = 0
Const GW\_HWNDNEXT = 2
Const GWL\_STYLE = (-16)
Const WS\_VISIBLE = &H10000000
Const WS\_BORDER = &H800000
Private Sub Command1\_Click()
Call GetWindowList
End Sub
Public Sub GetWindowList()
Dim hWnd As Long, sTitle As String, lStyle As Long, Task\_name() As String
Dim count As Integer, index As Integer, gefunden As Boolean
hWnd = FindWindow(ByVal 0&, ByVal 0&:wink:
hWnd = GetWindow(hWnd, GW\_HWNDFIRST)
Do
gefunden = False
lStyle = GetWindowLong(hWnd, GWL\_STYLE)
lStyle = lStyle And (WS\_VISIBLE Or WS\_BORDER)
sTitle = GetWindowTitle(hWnd)
If (lStyle = (WS\_VISIBLE Or WS\_BORDER)) = True Then
If Trim(sTitle) "" Then
For index = 1 To count
If Task\_name(index) = sTitle Then
gefunden = True
Exit For
End If
Next index
If Not gefunden Then
count = count + 1
ReDim Preserve Task\_name(1 To count)
Task\_name(count) = sTitle
End If
End If
End If
hWnd = GetWindow(hWnd, GW\_HWNDNEXT)
Loop Until hWnd = 0
For index = 1 To count
List1.AddItem Task\_name(index)
'Cells(index + 1, 1) = Task\_name(index)
'MsgBox Task\_name(index)
Next index
End Sub
Private Function GetWindowTitle(ByVal hWnd As Long) As String
Dim lResult As Long, sTemp As String
lResult = GetWindowTextLength(hWnd) + 1
sTemp = Space(lResult)
lResult = GetWindowText(hWnd, sTemp, lResult)
GetWindowTitle = Left(sTemp, Len(sTemp) - 1)
End Function