I think Stratos posted that more as an academic exercise rather than as his
suggested way to position a msgbox, and very clever it is too. He also said
"Therefore my suggestion would be if you
really need to position a message box use a userform or a baloon instead."
He did explain the code was for use in XL97 and as written it will only work
in XL97, later versions will not find vba332.dll. That library is only
required as part of the workaround for AddressOf which was n/a in xl97. In
later versions, in the function fncMsgBox_Pos97 include the following.
#If VBA6 Then
TempHook = SetWindowsHookEx _
( _
idHook:=WH_CBT, _
lpfn:=AddressOf cbkPositionMsgBox, _
hmod:=GetWindowLong(0, GWL_HINSTANCE), _
dwThreadId:=GetCurrentThreadId() _
)
#Else
TempHook = SetWindowsHookEx _
( _
idHook:=WH_CBT, _
lpfn:=AddrOf("cbkPositionMsgBox"), _
hmod:=GetWindowLong(0, GWL_HINSTANCE), _
dwThreadId:=GetCurrentThreadId() _
)
#End If
If no need to cater for xl97 remove the conditional #If, the AddrOf
function, and Declare Function GetCurrentVbaProject from the top of the
module.
Follow instructions carefully about where to put code and how to run (not in
the IDE, at least don't try to step through). Don't forget to add the
FindWindow API that was initially overlooked.
Regards,
Peter T