Windows API SendMessage

  • Thread starter Thread starter Tony Pinto
  • Start date Start date
T

Tony Pinto

I have seen a number of VB examples using the SendMessage
function on the web. However, the function does not appear
to work in VBA. "Member not found" error. Has anyone used
the SendMessage with VBA? Should there even be any
difference?
 
Hi,
As with all API functions, you have to declare it.
Usually in a standard module:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As
Integer, ByVal lParam As Any) As Long

The above should be all on one line.

You can now use the function.

Get the api guide, it's a great resource.

http://www.mentalis.org/agnet/apiguide.shtml
 
Dan generally SendMessage is declared as:

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
As Long

--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Dan Artuso said:
Hi,
As with all API functions, you have to declare it.
Usually in a standard module:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As
 
Well there you go, don't believe everything you read.
That declare was straight from the api guide so I didn't even
look twice at it.
 
Back
Top