Windows API SendMessage

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?
 
D

Dan Artuso

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
 
S

Stephen Lebans

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
 
D

Dan Artuso

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top