Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Self closing "modal" window ?

Hello !

I'm modifying an application written in Excel 2003 VBA.

After an operation ends, I'd like to display a confirmation message in
a window that will close itself after a given period of time (2
seconds).

This way, the user will get the feedback whithout having to click on a
MsgBox like "Ok" button.

I succesfully programmed a modeless form which will correctly do this
when used alone.

The problem is that in the application, this form is invoked from
another form which is modal. Upon displaying the confirmation message,
I get an error message saying that a non-modal window can't be open
while a modal window is open.

While making the calling modal form "modeless" may solve the problem in
that specific case, this worries me a little because this way, the user
can access the spreadsheet behind while the form is open and this is
not desired.

Searching on the net, I also found a code sample that uses the windows
api to simulate a "timer" object on a form, but was unsuccessful to
make it work.

Do anybody knows if this can be done, and if so, how ?

Thanks !


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Self closing "modal" window ?

Michel,
Whilst you cannot show a modeless form when a modal is shown, you can show
another modal form.

NickHK

"Michel S." wrote in message
...
Hello !

I'm modifying an application written in Excel 2003 VBA.

After an operation ends, I'd like to display a confirmation message in
a window that will close itself after a given period of time (2
seconds).

This way, the user will get the feedback whithout having to click on a
MsgBox like "Ok" button.

I succesfully programmed a modeless form which will correctly do this
when used alone.

The problem is that in the application, this form is invoked from
another form which is modal. Upon displaying the confirmation message,
I get an error message saying that a non-modal window can't be open
while a modal window is open.

While making the calling modal form "modeless" may solve the problem in
that specific case, this worries me a little because this way, the user
can access the spreadsheet behind while the form is open and this is
not desired.

Searching on the net, I also found a code sample that uses the windows
api to simulate a "timer" object on a form, but was unsuccessful to
make it work.

Do anybody knows if this can be done, and if so, how ?

Thanks !




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Self closing "modal" window ?

Thanks NickHK for your reply,

Here's a code snippet I use to Show the form and then close it two
seconds later :

Me.Show vbModeless
varTarget = DateAdd("s", 2, Now)
Do
DoEvents
Loop Until Now varTarget
Unload Me

The problem I face if I make the window modal is that when the code
reach the Me.Show (without vbModeless) statement, it sits there,
waiting for the user to do something. Since the code following is not
executed, the windows never closes itself.

As I said earlier, I found a code sample to simulate a Timer object
using the windows api to replace the above loop, but was unable to make
it work either.

Any idea ?


NickHK a couché sur son écran :
Michel,
Whilst you cannot show a modeless form when a modal is shown, you can show
another modal form.

NickHK

"Michel S." wrote in message
...
Hello !

I'm modifying an application written in Excel 2003 VBA.

After an operation ends, I'd like to display a confirmation message in
a window that will close itself after a given period of time (2
seconds).

This way, the user will get the feedback whithout having to click on a
MsgBox like "Ok" button.

I succesfully programmed a modeless form which will correctly do this
when used alone.

The problem is that in the application, this form is invoked from
another form which is modal. Upon displaying the confirmation message,
I get an error message saying that a non-modal window can't be open
while a modal window is open.

While making the calling modal form "modeless" may solve the problem in
that specific case, this worries me a little because this way, the user
can access the spreadsheet behind while the form is open and this is
not desired.

Searching on the net, I also found a code sample that uses the windows
api to simulate a "timer" object on a form, but was unsuccessful to
make it work.

Do anybody knows if this can be done, and if so, how ?

Thanks !



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Self closing "modal" window ?

Michel,
OK, I got you. Maybe one of these:
http://www.google.co.uk/search?hl=en... +Search&meta=

NickHK

"Michel S." wrote in message
...
Thanks NickHK for your reply,

Here's a code snippet I use to Show the form and then close it two
seconds later :

Me.Show vbModeless
varTarget = DateAdd("s", 2, Now)
Do
DoEvents
Loop Until Now varTarget
Unload Me

The problem I face if I make the window modal is that when the code
reach the Me.Show (without vbModeless) statement, it sits there,
waiting for the user to do something. Since the code following is not
executed, the windows never closes itself.

As I said earlier, I found a code sample to simulate a Timer object
using the windows api to replace the above loop, but was unable to make
it work either.

Any idea ?


NickHK a couché sur son écran :
Michel,
Whilst you cannot show a modeless form when a modal is shown, you can

show
another modal form.

NickHK

"Michel S." wrote in message
...
Hello !

I'm modifying an application written in Excel 2003 VBA.

After an operation ends, I'd like to display a confirmation message in
a window that will close itself after a given period of time (2
seconds).

This way, the user will get the feedback whithout having to click on a
MsgBox like "Ok" button.

I succesfully programmed a modeless form which will correctly do this
when used alone.

The problem is that in the application, this form is invoked from
another form which is modal. Upon displaying the confirmation message,
I get an error message saying that a non-modal window can't be open
while a modal window is open.

While making the calling modal form "modeless" may solve the problem in
that specific case, this worries me a little because this way, the user
can access the spreadsheet behind while the form is open and this is
not desired.

Searching on the net, I also found a code sample that uses the windows
api to simulate a "timer" object on a form, but was unsuccessful to
make it work.

Do anybody knows if this can be done, and if so, how ?

Thanks !





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Self closing "modal" window ?

You can use an OnTime procedure to dismiss the form after a certain period
of time. In a standard code module, use code like the following:

Public RunWhen As Double

Sub ShowTheForm()
RunWhen = Now + TimeSerial(0, 0, 10) ' close 10 seconds from now
Application.OnTime RunWhen, "CloseTheForm"
UserForm1.Show vbModal
End Sub

Sub CloseTheForm()
Unload UserForm1
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Michel S." wrote in message
...
Thanks NickHK for your reply,

Here's a code snippet I use to Show the form and then close it two seconds
later :

Me.Show vbModeless
varTarget = DateAdd("s", 2, Now)
Do
DoEvents
Loop Until Now varTarget
Unload Me

The problem I face if I make the window modal is that when the code reach
the Me.Show (without vbModeless) statement, it sits there, waiting for the
user to do something. Since the code following is not executed, the
windows never closes itself.

As I said earlier, I found a code sample to simulate a Timer object using
the windows api to replace the above loop, but was unable to make it work
either.

Any idea ?


NickHK a couché sur son écran :
Michel,
Whilst you cannot show a modeless form when a modal is shown, you can
show
another modal form.

NickHK

"Michel S." wrote in message
...
Hello !

I'm modifying an application written in Excel 2003 VBA.

After an operation ends, I'd like to display a confirmation message in
a window that will close itself after a given period of time (2
seconds).

This way, the user will get the feedback whithout having to click on a
MsgBox like "Ok" button.

I succesfully programmed a modeless form which will correctly do this
when used alone.

The problem is that in the application, this form is invoked from
another form which is modal. Upon displaying the confirmation message,
I get an error message saying that a non-modal window can't be open
while a modal window is open.

While making the calling modal form "modeless" may solve the problem in
that specific case, this worries me a little because this way, the user
can access the spreadsheet behind while the form is open and this is
not desired.

Searching on the net, I also found a code sample that uses the windows
api to simulate a "timer" object on a form, but was unsuccessful to
make it work.

Do anybody knows if this can be done, and if so, how ?

Thanks !





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
Follow link from Window("1") in Window("2") possible? Dennis Excel Programming 1 December 6th 06 04:29 AM
Excel Dialog being "Non-Modal"? [email protected] Excel Programming 0 November 24th 06 10:45 PM
Excel 2003 VBA - "Maximizing" Window & "Calculating" Workbook JingleRock Excel Programming 0 April 25th 06 05:04 AM
freeze window creates multiple "views" suffixed with ":n" dgaex001 Excel Discussion (Misc queries) 5 March 22nd 06 05:28 PM
VBA command to say "yes"/"no" to popup window Manuel Excel Programming 7 August 5th 04 10:20 AM


All times are GMT +1. The time now is 06:29 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"