K
Karl E. Peterson
Hi Folks --
Is there any sort of agreed upon "best practice" for obtaining the hWnd of VBA
UserForms? Something that'll pretty much work wherever VBA may be found? I seem to
generally use some variation of this:
Option Explicit
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private hWnd As Long
Private Sub UserForm_Activate()
hWnd = GetForegroundWindow()
Debug.Print Hex$(hWnd)
End Sub
But I'm pretty much only working in either Word or Excel, and version 2003 at that.
Any reason to think that wouldn't work in PowerPoint, Access, 2007, 2000, elsewhere,
....? Is there a better (more universal) way?
Thanks... Karl
Is there any sort of agreed upon "best practice" for obtaining the hWnd of VBA
UserForms? Something that'll pretty much work wherever VBA may be found? I seem to
generally use some variation of this:
Option Explicit
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private hWnd As Long
Private Sub UserForm_Activate()
hWnd = GetForegroundWindow()
Debug.Print Hex$(hWnd)
End Sub
But I'm pretty much only working in either Word or Excel, and version 2003 at that.
Any reason to think that wouldn't work in PowerPoint, Access, 2007, 2000, elsewhere,
....? Is there a better (more universal) way?
Thanks... Karl