I just figured out the solution, and it'd so dumb I want to cry. Today is most certainly monday.
When I put in the declaration, (I can't for the life of me figure out how it happened as I found where i got the code and it did not have the error) I declared the api with:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As Long) As Long
anyone see the issue? I put As Long
next to ByVal lpWindowName
when it obviously should be string. UGH!
As an aside, I found an interesting articule about windows 7 32 and 64-bit / VBA7 compatibility which I'd like to post. Apparently most api functions in windows 7 64-bit should be declared using ptrSafe
. so for example, if I was usign 64-bit I should declare that api as:
Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
heres a link to where I found that: http://msdn.microsoft.com/en-us/library/ff700513(v=office.11)
that one mentions VBA7, this one mentions 32 vs 64-bit windows: http://www.jkp-ads.com/articles/apideclarations.asp
Thanks much for any views and considerations!