samedi 18 avril 2015

Excel 2013 Windows Class Names

Have to learn a little API for my VBA project so am experimenting. The interwebs suggests this code should work in a sub to find a windowshandle



Private Declare PtrSafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr

Public Sub Test()
Dim P As String
P = Windows(1).Caption
MsgBox P
MsgBox FindWindowA("", P)
End Sub


With a sheet open with caption "Book1.xlsm" when I run this code I get "Book1.xlsm" but then "0"


What am I doing wrong? If I try "EXCEL7" as a class name instead of the null string, I get the same thing.


Thanks to those older and wiser


Aucun commentaire:

Enregistrer un commentaire