Thread: [Solved] CommandBars in powerpoint
View Single Post
 
Old 02-24-2014, 02:48 AM
JohnWilson JohnWilson is offline Windows 7 64bit Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,913
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

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.
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote