Peter T wrote:
Well hello again Karl!
As Rick says it's -
hWnd = FindWindow("ThunderDFrame", Me.Caption)
That's good for Excel 2000+ and AFAIK all Office 2000 or later with VBA6.
Good to know!
If you want to cater for anyone still using Office97 (most don't but I do) -
Ewww, no. Not anymore, thanks. :-)
If Val(Application.Version) = 9 Then
sClassName = "ThunderDFrame"
Else
sClassName = "ThunderXFrame"
End If
Still, a good nugget to have.
instead of checking the app version you could do
#If VBA6 ... #Else If ... #End IF
but will need a bit more for 2010/64bit
As I recall, and this is a very dim memory, that constant is predefined in VBA,
right? So I can use it in normal VB6 code, and it'll only come into play if the
code is sucked into VBA? I keep forgetting that. It's an incredibly useful tidbit!
If there's any possibility a form with a similar caption could be showing
elsewhere, even in another instance, best to temporarily change the caption
to something unique.
Yep. That's one of the reasons I tended against the FindWindow approach, as well.
But the GetActiveWindow approach is going to work pretty well, I think.
--
..NET: It's About Trust!
http://vfred.mvps.org