Not sure how you are running the code with a modal dialog open.
BUT
The header and Footer is a Dialog class window "#32770"
so:
#If VBA7 Then
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
#Else
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If
Sub chex()
Dim wName As String
Dim hWnd
Dim lpClass As String
wName = "Header and Footer"
lpClass = "#32770"
hWnd = FindWindow(lpClass, wName)
If hWnd = 0 Then
MsgBox "Dialog window is not open"
Else
MsgBox "Dialog window is open"
End If
End Sub
If you are opening the dialog in code you will need to incorporate a delay before checking to allow the window to open otherwise it will always show as closed.
|