Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Position of MsgBox

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default Position of MsgBox

Otto

Someone may know how to control the position of a msgbox, but, it
would be pretty easy to control the position of a userform that looks
and acts like a msgbox; in case that will work.

Ken


On May 16, 3:07*pm, "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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Position of MsgBox

See:

http://groups.google.com/group/micro...c6d98b98fb7aca
--
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Position of MsgBox

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" wrote in message
...
See:


http://groups.google.com/group/micro...c6d98b98fb7aca
--
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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Position of MsgBox

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" wrote in message
...
See:


http://groups.google.com/group/micro...c6d98b98fb7aca
--
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








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Position of MsgBox

Yes. How is that done? Otto
"Gary''s Student" wrote in message
...
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" wrote in
message
...
See:


http://groups.google.com/group/micro...c6d98b98fb7aca
--
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








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Position of MsgBox

When I thought about the problem with more coffee in me, I realized that
there is a sort of Catch-22. Once the VBA has popped up the MsgBox, it has
lost focus ("sleeping"), waiting for the user to respond. Anyway here is
another reference:

http://groups.google.com/group/micro...26b8c4f39aa019
--
Gary''s Student - gsnu200786


"Otto Moehrbach" wrote:

Yes. How is that done? Otto
"Gary''s Student" wrote in message
...
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" wrote in
message
...
See:


http://groups.google.com/group/micro...c6d98b98fb7aca
--
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









  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Position of MsgBox

As you say, code is suspended until the msgbox is dismissed. Did either of
you actually try the demo by Stratos. I only ask because your similar
questions implied either you didn't or you couldn't get it to work. It
worked fine for me after adapting for post xl97 versions along the lines I
suggested.

Although the demo in the link below (by Jim Rech) looks different, in
essence the hook method is pretty much the same. Jim's includes an
extra"feature" in that it returns the size of the msgbox, so with a bit of
math's would allow the msgbox to be centred over a userform, for example.

Regards,
Peter T

"Gary''s Student" wrote in message
...
When I thought about the problem with more coffee in me, I realized that
there is a sort of Catch-22. Once the VBA has popped up the MsgBox, it

has
lost focus ("sleeping"), waiting for the user to respond. Anyway here is
another reference:


http://groups.google.com/group/micro...26b8c4f39aa019
--
Gary''s Student - gsnu200786


"Otto Moehrbach" wrote:

Yes. How is that done? Otto
"Gary''s Student" wrote in

message
...
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" wrote in
message
...
See:



http://groups.google.com/group/micro...c6d98b98fb7aca
--
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











Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MsgBox Position Dewald Excel Programming 2 October 14th 05 01:11 PM
MsgBox position RJH Excel Programming 2 August 19th 04 08:49 AM
MsgBox position Jeff[_33_] Excel Programming 2 June 14th 04 10:14 PM
Determine the position of a MsgBox Tom Excel Programming 0 August 9th 03 02:36 PM
Position of MsgBox Konrad[_2_] Excel Programming 0 August 7th 03 05:27 PM


All times are GMT +1. The time now is 12:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"