AddressOf / Windows API question

A

Amos

I am trying to write a piece of code that will determine
the address of a routine/function that will work in both
Office 97 and Office XP. I am needing this address for use
in using some of the Windows API functionality. I have
found a piece of code that helps me do this for VBE 5
(Office 97). The problem now is getting this functionality
in VBE 6(Office XP). I have read on a few sites that VBE 6
has a built-in 'AddressOf' function. This would suit my
needs perfectly, but the VB Editor does not recognize this
function. Do I need a reference to a particular library or
something?

Thanks in advance for your responses.
- Amos -
 
B

Bob Phillips

Amos,

I presume that you mean Ken Getz;'s routine. Here is an example that I use

Public Function fncWindowsTimer(TimeInterval As Long, WindowsTimer As Long)
As Boolean
WindowsTimer = 0
'if Excel2000 or above use the built-in AddressOf operator to
'get a pointer to the callback function
If Val(Application.Version) > 8 Then
WindowsTimer = SetTimer(hWnd:=FindWindow("XLMAIN",
Application.Caption), _
nIDEvent:=0, _
uElapse:=TimeInterval, _
lpTimerFunc:=AddrOf_Callback_Routine)
Else 'use K.Getz & M.Kaplan function to get a pointer
WindowsTimer = SetTimer(hWnd:=FindWindow("XLMAIN",
Application.Caption), _
nIDEvent:=0, _
uElapse:=TimeInterval, _
lpTimerFunc:=AddrOf("cbkRoutine"))
End If

fncWindowsTimer = CBool(WindowsTimer)

End Function


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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