Re: Position of MsgBox

Tech-Archive recommends: Fix windows errors by optimizing your registry



Peter:

Might it be possible to first create the MsgBox (where ever Excel want to
put it) and then move it to some location with VBA??
--
Gary''s Student - gsnu200786


"Peter T" wrote:

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


"Gary''s Student" <GarysStudent@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CC10BED2-E5D6-4443-B847-32B3BB6BC532@xxxxxxxxxxxxxxxx
See:


http://groups.google.com/group/microsoft.public.excel.programming/msg/67c6d98b98fb7aca
--
Gary''s Student - gsnu2007h


"Otto Moehrbach" wrote:

Excel XP & 2007
An OP has asked me if there is a way to control the position of a MsgBox
on
the screen. I know of no way to do that. Is that possible? Thanks for
your time. Otto






.



Relevant Pages

  • Re: Position of MsgBox
    ... "Otto Moehrbach" wrote: ... Might it be possible to first create the MsgBox (where ever Excel want to ... put it) and then move it to some location with VBA?? ... He did explain the code was for use in XL97 and as written it will only ...
    (microsoft.public.excel.programming)
  • Re: Position of MsgBox
    ... "Therefore my suggestion would be if you ... He did explain the code was for use in XL97 and as written it will only work ... "Otto Moehrbach" wrote: ... An OP has asked me if there is a way to control the position of a MsgBox ...
    (microsoft.public.excel.programming)
  • Re: Position of MsgBox
    ... code is suspended until the msgbox is dismissed. ... Gary''s Student - gsnu200786 ... "Otto Moehrbach" wrote: ... He did explain the code was for use in XL97 and as written it will ...
    (microsoft.public.excel.programming)
  • RE: Position of MsgBox
    ... Gary''s Student - gsnu2007h ... "Otto Moehrbach" wrote: ... An OP has asked me if there is a way to control the position of a MsgBox on ...
    (microsoft.public.excel.programming)
  • Re: SpecialCells problem
    ... Gary's Student ... Sub Demo() ... MsgBox ... Similar to when you highlight a single cell and select ...
    (microsoft.public.excel.programming)