-
Hi. I am working in a VBA environment under Word97. Since I need a CallByName function for that environment(which is close to vba5) i made my own CallByName routine using the function SendMessageCallback.
SendMessageCallback(hwnd, 256&, 16&, 2752513, AddrOf("MyFunction"), DataToGive)
(AddrOf is a function that returns the address of a function, using API in the VBA332.dll, since AdressOf doesn't exist in VBA(97))
I can pass through the DataToGive parameter to "MyFunction" as a long parameter. That works well. When I try to pass a String to the function. The MyFunction only gets a number representing an address to a memory location where the string is. Do anyone know how I can create a pointer to get this string?
-
Might have found a solution.
Code:
Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(lpvDest As Any, _
lpvSource As Any, _
ByVal cbCopy As Long)
Function MyFunction(ByVal hwnd As Long, ByVal umsg As Long, ByVal DataToGive As Long, ByVal lresult As Long) As Long
Dim b(1 To 10) As Byte
CopyMemory b(1), ByVal DataToGive, 10
For i = 1 To 10
Debug.Print Chr(b(i));
Next
End Function
The Debug.Print writes out the string. If anyone else has anything they want to add, please do.