PC Review


Reply
Thread Tools Rate Thread

Close msgbox after making selection

 
 
John Keith
Guest
Posts: n/a
 
      31st Mar 2010
I make use of a msgbox with Yes/No buttons fairly frequently, like:

answer = msgbox("Do you want to proceed?", vbyesno)

After clicking on the desired button the message box window remains
open. Is there a way to force closing this window as soon as the
variable is read?


John Keith
(E-Mail Removed)
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      31st Mar 2010
Is this a message box that was created with a UserForm? The standard
message box automatically closes when a button is clicked. If it is the
standard message box and is not closing, there could be a software problem
in your system. Is this in Excel, if so, what version.


"John Keith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I make use of a msgbox with Yes/No buttons fairly frequently, like:
>
> answer = msgbox("Do you want to proceed?", vbyesno)
>
> After clicking on the desired button the message box window remains
> open. Is there a way to force closing this window as soon as the
> variable is read?
>
>
> John Keith
> (E-Mail Removed)



 
Reply With Quote
 
John Keith
Guest
Posts: n/a
 
      31st Mar 2010
>Is this a message box that was created with a UserForm?

No

> The standard message box automatically closes when a button is clicked. If it is the
>standard message box and is not closing, there could be a software problem
>in your system. Is this in Excel, if so, what version.


Excel 2007/WinXP

The message box window stays open until the next msgbox command is
executed.

I also just tried the following

msgbox("Test")
for i =1 to 100000000
a=1
next i
msgbox("done")

The loop has not completed yet and the first message box is still
open.





John Keith
(E-Mail Removed)
 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      31st Mar 2010
What you describe cannot and occur. I very much doubt you actually tested
the code you posted as an example, at least not exactly as written and with
nothing else.

My guess is you are showing the msgbox with screenupdating disabled. The
msgbox will stay on the screen indefinitely until the screen is refreshed
(even DoEvents) or by re-enabling screenupdating.

Be sure to temporarily disable screenupdating if/as necessary when showing a
msgbox.

Regards,
Peter T

The only thing that
"John Keith" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> >Is this a message box that was created with a UserForm?

>
> No
>
>> The standard message box automatically closes when a button is clicked.
>> If it is the
>>standard message box and is not closing, there could be a software problem
>>in your system. Is this in Excel, if so, what version.

>
> Excel 2007/WinXP
>
> The message box window stays open until the next msgbox command is
> executed.
>
> I also just tried the following
>
> msgbox("Test")
> for i =1 to 100000000
> a=1
> next i
> msgbox("done")
>
> The loop has not completed yet and the first message box is still
> open.
>
>
>
>
>
> John Keith
> (E-Mail Removed)



 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      31st Mar 2010
I can't duplicate the problem in xl2003, but it sounds like a software
glitch to me. The standard message box is designed to close immediately
upon execution of a button. Unless xl2007 has an option to open the message
box as modeless, I cannot offer any explanation for the behavior.




"John Keith" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> >Is this a message box that was created with a UserForm?

>
> No
>
>> The standard message box automatically closes when a button is clicked.
>> If it is the
>>standard message box and is not closing, there could be a software problem
>>in your system. Is this in Excel, if so, what version.

>
> Excel 2007/WinXP
>
> The message box window stays open until the next msgbox command is
> executed.
>
> I also just tried the following
>
> msgbox("Test")
> for i =1 to 100000000
> a=1
> next i
> msgbox("done")
>
> The loop has not completed yet and the first message box is still
> open.
>
>
>
>
>
> John Keith
> (E-Mail Removed)



 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      31st Mar 2010
Hi Peter, In the version of xl03 that I am running, the msgbox goes away,
whether or not ScreenUpdating is enabled. Is it different in xl07 + ?


"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
> What you describe cannot and occur. I very much doubt you actually tested
> the code you posted as an example, at least not exactly as written and
> with nothing else.
>
> My guess is you are showing the msgbox with screenupdating disabled. The
> msgbox will stay on the screen indefinitely until the screen is refreshed
> (even DoEvents) or by re-enabling screenupdating.
>
> Be sure to temporarily disable screenupdating if/as necessary when showing
> a msgbox.
>
> Regards,
> Peter T
>
> The only thing that
> "John Keith" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
>> >Is this a message box that was created with a UserForm?

>>
>> No
>>
>>> The standard message box automatically closes when a button is clicked.
>>> If it is the
>>>standard message box and is not closing, there could be a software
>>>problem
>>>in your system. Is this in Excel, if so, what version.

>>
>> Excel 2007/WinXP
>>
>> The message box window stays open until the next msgbox command is
>> executed.
>>
>> I also just tried the following
>>
>> msgbox("Test")
>> for i =1 to 100000000
>> a=1
>> next i
>> msgbox("done")
>>
>> The loop has not completed yet and the first message box is still
>> open.
>>
>>
>>
>>
>>
>> John Keith
>> (E-Mail Removed)

>
>



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      31st Mar 2010
Try this

Sub abc()
' run with alt-F8
Dim a

'Application.ScreenUpdating = False

MsgBox ("Move me away from the centre of the screen")

Application.ScreenUpdating = False
For i = 1 To 100
a = 1
Next i
MsgBox ("done")
Application.ScreenUpdating = True
End Sub

Regards,
Peter T


"JLGWhiz" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi Peter, In the version of xl03 that I am running, the msgbox goes
> away, whether or not ScreenUpdating is enabled. Is it different in xl07 +
> ?
>
>
> "Peter T" <peter_t@discussions> wrote in message
> news:(E-Mail Removed)...
>> What you describe cannot and occur. I very much doubt you actually tested
>> the code you posted as an example, at least not exactly as written and
>> with nothing else.
>>
>> My guess is you are showing the msgbox with screenupdating disabled. The
>> msgbox will stay on the screen indefinitely until the screen is refreshed
>> (even DoEvents) or by re-enabling screenupdating.
>>
>> Be sure to temporarily disable screenupdating if/as necessary when
>> showing a msgbox.
>>
>> Regards,
>> Peter T
>>
>> The only thing that
>> "John Keith" <(E-Mail Removed)> wrote in message
>> news(E-Mail Removed)...
>>> >Is this a message box that was created with a UserForm?
>>>
>>> No
>>>
>>>> The standard message box automatically closes when a button is clicked.
>>>> If it is the
>>>>standard message box and is not closing, there could be a software
>>>>problem
>>>>in your system. Is this in Excel, if so, what version.
>>>
>>> Excel 2007/WinXP
>>>
>>> The message box window stays open until the next msgbox command is
>>> executed.
>>>
>>> I also just tried the following
>>>
>>> msgbox("Test")
>>> for i =1 to 100000000
>>> a=1
>>> next i
>>> msgbox("done")
>>>
>>> The loop has not completed yet and the first message box is still
>>> open.
>>>
>>>
>>>
>>>
>>>
>>> John Keith
>>> (E-Mail Removed)

>>
>>

>
>



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      31st Mar 2010
Forgot to mention I get same results in 2003 & 2007

Peter T

"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
> Try this
>
> Sub abc()
> ' run with alt-F8
> Dim a
>
> 'Application.ScreenUpdating = False
>
> MsgBox ("Move me away from the centre of the screen")
>
> Application.ScreenUpdating = False
> For i = 1 To 100
> a = 1
> Next i
> MsgBox ("done")
> Application.ScreenUpdating = True
> End Sub
>
> Regards,
> Peter T
>
>
> "JLGWhiz" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi Peter, In the version of xl03 that I am running, the msgbox goes
>> away, whether or not ScreenUpdating is enabled. Is it different in xl07
>> + ?
>>
>>
>> "Peter T" <peter_t@discussions> wrote in message
>> news:(E-Mail Removed)...
>>> What you describe cannot and occur. I very much doubt you actually
>>> tested the code you posted as an example, at least not exactly as
>>> written and with nothing else.
>>>
>>> My guess is you are showing the msgbox with screenupdating disabled. The
>>> msgbox will stay on the screen indefinitely until the screen is
>>> refreshed (even DoEvents) or by re-enabling screenupdating.
>>>
>>> Be sure to temporarily disable screenupdating if/as necessary when
>>> showing a msgbox.
>>>
>>> Regards,
>>> Peter T
>>>
>>> The only thing that
>>> "John Keith" <(E-Mail Removed)> wrote in message
>>> news(E-Mail Removed)...
>>>> >Is this a message box that was created with a UserForm?
>>>>
>>>> No
>>>>
>>>>> The standard message box automatically closes when a button is
>>>>> clicked. If it is the
>>>>>standard message box and is not closing, there could be a software
>>>>>problem
>>>>>in your system. Is this in Excel, if so, what version.
>>>>
>>>> Excel 2007/WinXP
>>>>
>>>> The message box window stays open until the next msgbox command is
>>>> executed.
>>>>
>>>> I also just tried the following
>>>>
>>>> msgbox("Test")
>>>> for i =1 to 100000000
>>>> a=1
>>>> next i
>>>> msgbox("done")
>>>>
>>>> The loop has not completed yet and the first message box is still
>>>> open.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> John Keith
>>>> (E-Mail Removed)
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      31st Mar 2010
Nope, As soon as I click the button, the shape dialog box disappears. I
cannot get it to remain on screen after the button is clicked and cannot get
any further code to process without clicking the button. I believe that is
the designed performance.



"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
> Try this
>
> Sub abc()
> ' run with alt-F8
> Dim a
>
> 'Application.ScreenUpdating = False
>
> MsgBox ("Move me away from the centre of the screen")
>
> Application.ScreenUpdating = False
> For i = 1 To 100
> a = 1
> Next i
> MsgBox ("done")
> Application.ScreenUpdating = True
> End Sub
>
> Regards,
> Peter T
>
>
> "JLGWhiz" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi Peter, In the version of xl03 that I am running, the msgbox goes
>> away, whether or not ScreenUpdating is enabled. Is it different in xl07
>> + ?
>>
>>
>> "Peter T" <peter_t@discussions> wrote in message
>> news:(E-Mail Removed)...
>>> What you describe cannot and occur. I very much doubt you actually
>>> tested the code you posted as an example, at least not exactly as
>>> written and with nothing else.
>>>
>>> My guess is you are showing the msgbox with screenupdating disabled. The
>>> msgbox will stay on the screen indefinitely until the screen is
>>> refreshed (even DoEvents) or by re-enabling screenupdating.
>>>
>>> Be sure to temporarily disable screenupdating if/as necessary when
>>> showing a msgbox.
>>>
>>> Regards,
>>> Peter T
>>>
>>> The only thing that
>>> "John Keith" <(E-Mail Removed)> wrote in message
>>> news(E-Mail Removed)...
>>>> >Is this a message box that was created with a UserForm?
>>>>
>>>> No
>>>>
>>>>> The standard message box automatically closes when a button is
>>>>> clicked. If it is the
>>>>>standard message box and is not closing, there could be a software
>>>>>problem
>>>>>in your system. Is this in Excel, if so, what version.
>>>>
>>>> Excel 2007/WinXP
>>>>
>>>> The message box window stays open until the next msgbox command is
>>>> executed.
>>>>
>>>> I also just tried the following
>>>>
>>>> msgbox("Test")
>>>> for i =1 to 100000000
>>>> a=1
>>>> next i
>>>> msgbox("done")
>>>>
>>>> The loop has not completed yet and the first message box is still
>>>> open.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> John Keith
>>>> (E-Mail Removed)
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      31st Mar 2010
Indeed it is normal behaviour for the code to be suspended until the msgbox
is dismissed. But are you saying with screenupdating disabled the "image" of
the msgbox completely disappears from the screen after clicking OK.

Regards,
Peter T

"JLGWhiz" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Nope, As soon as I click the button, the shape dialog box disappears. I
> cannot get it to remain on screen after the button is clicked and cannot
> get any further code to process without clicking the button. I believe
> that is the designed performance.
>
>
>
> "Peter T" <peter_t@discussions> wrote in message
> news:(E-Mail Removed)...
>> Try this
>>
>> Sub abc()
>> ' run with alt-F8
>> Dim a
>>
>> 'Application.ScreenUpdating = False
>>
>> MsgBox ("Move me away from the centre of the screen")
>>
>> Application.ScreenUpdating = False
>> For i = 1 To 100
>> a = 1
>> Next i
>> MsgBox ("done")
>> Application.ScreenUpdating = True
>> End Sub
>>
>> Regards,
>> Peter T
>>
>>
>> "JLGWhiz" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Hi Peter, In the version of xl03 that I am running, the msgbox goes
>>> away, whether or not ScreenUpdating is enabled. Is it different in xl07
>>> + ?
>>>
>>>
>>> "Peter T" <peter_t@discussions> wrote in message
>>> news:(E-Mail Removed)...
>>>> What you describe cannot and occur. I very much doubt you actually
>>>> tested the code you posted as an example, at least not exactly as
>>>> written and with nothing else.
>>>>
>>>> My guess is you are showing the msgbox with screenupdating disabled.
>>>> The msgbox will stay on the screen indefinitely until the screen is
>>>> refreshed (even DoEvents) or by re-enabling screenupdating.
>>>>
>>>> Be sure to temporarily disable screenupdating if/as necessary when
>>>> showing a msgbox.
>>>>
>>>> Regards,
>>>> Peter T
>>>>
>>>> The only thing that
>>>> "John Keith" <(E-Mail Removed)> wrote in message
>>>> news(E-Mail Removed)...
>>>>> >Is this a message box that was created with a UserForm?
>>>>>
>>>>> No
>>>>>
>>>>>> The standard message box automatically closes when a button is
>>>>>> clicked. If it is the
>>>>>>standard message box and is not closing, there could be a software
>>>>>>problem
>>>>>>in your system. Is this in Excel, if so, what version.
>>>>>
>>>>> Excel 2007/WinXP
>>>>>
>>>>> The message box window stays open until the next msgbox command is
>>>>> executed.
>>>>>
>>>>> I also just tried the following
>>>>>
>>>>> msgbox("Test")
>>>>> for i =1 to 100000000
>>>>> a=1
>>>>> next i
>>>>> msgbox("done")
>>>>>
>>>>> The loop has not completed yet and the first message box is still
>>>>> open.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> John Keith
>>>>> (E-Mail Removed)
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
If Selection <> 0 then msgbox Ron Microsoft Excel Programming 5 28th Apr 2009 05:06 PM
Msgbox Close with vba art Microsoft Excel Programming 10 20th Nov 2008 01:23 PM
MsgBox based upon Combo Box Selection =?Utf-8?B?Y2xhcmtudg==?= Microsoft Access VBA Modules 4 13th Feb 2007 05:09 PM
Why my selection is lost with MsgBox? =?Utf-8?B?TUxldmVzcXVl?= Microsoft Excel Programming 6 9th Aug 2005 05:10 AM
Making a Msgbox popup Todd Huttenstine Microsoft Excel Programming 5 28th Dec 2003 10:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 PM.