PC Review


Reply
Thread Tools Rate Thread

Close msgbox automatically

 
 
EXCELMACROS
Guest
Posts: n/a
 
      30th Dec 2008
Hello, me again.., I'm trying to close a msgbox using application.ontime now
+ 5seg

Thank you in advance
--
Thank you...
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      30th Dec 2008
Hi,

How about this which auto closes after 5 seconds or sooner if the user
presses OK

CreateObject("WScript.Shell").popup "Your Message", 5

Mike

"EXCELMACROS" wrote:

> Hello, me again.., I'm trying to close a msgbox using application.ontime now
> + 5seg
>
> Thank you in advance
> --
> Thank you...

 
Reply With Quote
 
EXCELMACROS
Guest
Posts: n/a
 
      30th Dec 2008
I need to close it in 5 seg, can't wait for the user to press "ok" what do
you think?
--
Thank you...


"Mike H" wrote:

> Hi,
>
> How about this which auto closes after 5 seconds or sooner if the user
> presses OK
>
> CreateObject("WScript.Shell").popup "Your Message", 5
>
> Mike
>
> "EXCELMACROS" wrote:
>
> > Hello, me again.., I'm trying to close a msgbox using application.ontime now
> > + 5seg
> >
> > Thank you in advance
> > --
> > Thank you...

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      30th Dec 2008
I think you need to go back and read my post again.

> > How about this which auto closes after 5 seconds or sooner if the user
> > presses OK


Mike


"EXCELMACROS" wrote:

> I need to close it in 5 seg, can't wait for the user to press "ok" what do
> you think?
> --
> Thank you...
>
>
> "Mike H" wrote:
>
> > Hi,
> >
> > How about this which auto closes after 5 seconds or sooner if the user
> > presses OK
> >
> > CreateObject("WScript.Shell").popup "Your Message", 5
> >
> > Mike
> >
> > "EXCELMACROS" wrote:
> >
> > > Hello, me again.., I'm trying to close a msgbox using application.ontime now
> > > + 5seg
> > >
> > > Thank you in advance
> > > --
> > > Thank you...

 
Reply With Quote
 
EXCELMACROS
Guest
Posts: n/a
 
      30th Dec 2008
Well, I did copy paste exactly what you suggested and is not closing in 5
seg...
--
Thank you...


"Mike H" wrote:

> I think you need to go back and read my post again.
>
> > > How about this which auto closes after 5 seconds or sooner if the user
> > > presses OK

>
> Mike
>
>
> "EXCELMACROS" wrote:
>
> > I need to close it in 5 seg, can't wait for the user to press "ok" what do
> > you think?
> > --
> > Thank you...
> >
> >
> > "Mike H" wrote:
> >
> > > Hi,
> > >
> > > How about this which auto closes after 5 seconds or sooner if the user
> > > presses OK
> > >
> > > CreateObject("WScript.Shell").popup "Your Message", 5
> > >
> > > Mike
> > >
> > > "EXCELMACROS" wrote:
> > >
> > > > Hello, me again.., I'm trying to close a msgbox using application.ontime now
> > > > + 5seg
> > > >
> > > > Thank you in advance
> > > > --
> > > > Thank you...

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      30th Dec 2008
Hi,

Then I'm at a loss to understand why. I don't believe you need to set any
references to make this work but perhaps someone else can enlighten us (me).
Once again for me it displays for 5 seconds and then auto closes.

I'll post it again in case tit became corrupted last time

CreateObject("WScript.Shell").Popup "Your Message", 5, "User Message"

Mike

Mike

"EXCELMACROS" wrote:

> Well, I did copy paste exactly what you suggested and is not closing in 5
> seg...
> --
> Thank you...
>
>
> "Mike H" wrote:
>
> > I think you need to go back and read my post again.
> >
> > > > How about this which auto closes after 5 seconds or sooner if the user
> > > > presses OK

> >
> > Mike
> >
> >
> > "EXCELMACROS" wrote:
> >
> > > I need to close it in 5 seg, can't wait for the user to press "ok" what do
> > > you think?
> > > --
> > > Thank you...
> > >
> > >
> > > "Mike H" wrote:
> > >
> > > > Hi,
> > > >
> > > > How about this which auto closes after 5 seconds or sooner if the user
> > > > presses OK
> > > >
> > > > CreateObject("WScript.Shell").popup "Your Message", 5
> > > >
> > > > Mike
> > > >
> > > > "EXCELMACROS" wrote:
> > > >
> > > > > Hello, me again.., I'm trying to close a msgbox using application.ontime now
> > > > > + 5seg
> > > > >
> > > > > Thank you in advance
> > > > > --
> > > > > Thank you...

 
Reply With Quote
 
EXCELMACROS
Guest
Posts: n/a
 
      30th Dec 2008
Sorry Mike, It won't close until I press "OK" Thank you so much for your
help...
--
Thank you...


"Mike H" wrote:

> Hi,
>
> Then I'm at a loss to understand why. I don't believe you need to set any
> references to make this work but perhaps someone else can enlighten us (me).
> Once again for me it displays for 5 seconds and then auto closes.
>
> I'll post it again in case tit became corrupted last time
>
> CreateObject("WScript.Shell").Popup "Your Message", 5, "User Message"
>
> Mike
>
> Mike
>
> "EXCELMACROS" wrote:
>
> > Well, I did copy paste exactly what you suggested and is not closing in 5
> > seg...
> > --
> > Thank you...
> >
> >
> > "Mike H" wrote:
> >
> > > I think you need to go back and read my post again.
> > >
> > > > > How about this which auto closes after 5 seconds or sooner if the user
> > > > > presses OK
> > >
> > > Mike
> > >
> > >
> > > "EXCELMACROS" wrote:
> > >
> > > > I need to close it in 5 seg, can't wait for the user to press "ok" what do
> > > > you think?
> > > > --
> > > > Thank you...
> > > >
> > > >
> > > > "Mike H" wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > How about this which auto closes after 5 seconds or sooner if the user
> > > > > presses OK
> > > > >
> > > > > CreateObject("WScript.Shell").popup "Your Message", 5
> > > > >
> > > > > Mike
> > > > >
> > > > > "EXCELMACROS" wrote:
> > > > >
> > > > > > Hello, me again.., I'm trying to close a msgbox using application.ontime now
> > > > > > + 5seg
> > > > > >
> > > > > > Thank you in advance
> > > > > > --
> > > > > > Thank you...

 
Reply With Quote
 
EXCELMACROS
Guest
Posts: n/a
 
      30th Dec 2008
Sorry Leith, it did not work. I have to click "OK" for it to close...
--
Thank you...


"Leith Ross" wrote:

>
> Hello EXCELMACROS,
>
> Here is macro to close the dialog after 5 seconds. You can change this
> to suite your needs.
>
> Code:
> --------------------
>
> Sub TimedMsgBox()
>
> Dim Msg As String
> Dim Secs As Long
> Dim Wsh As Object
>
> Title = "Test"
> Msg = "This will close in 5 seconds."
> Secs = 5
>
> Set Wsh = CreateObject("WScript.Shell")
> RetVal = Wsh.Popup(Msg, Secs, Title, vbInformation + vbOKOnly)
> Set Wsh = Nothing
>
> End Sub
>
> --------------------
>
> Sincerely,
> Leith Ross
>
>
> --
> Leith Ross
> ------------------------------------------------------------------------
> Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
> View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=45231
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      30th Dec 2008
The WScript.Shell - popup method is not reliable to dismiss a msgbox. It may
work in some machines, not at all, or erratically (does not seem to relate
to windows version).

Best way is make a userform to look like a msgbox, perhaps pass a message to
a label caption and include some sort of timer to dismiss the form if still
showing after say 5 seconds, eg

' userform code
Private mbShow As Boolean

Private Sub UserForm_Activate()
Dim t As Single
Dim ShowTime As Single

mbShow = True

ShowTime = 5
t = Timer

While (Timer < ShowTime + t) And mbShow
DoEvents
Wend

If mbShow Then
Unload Me
End If
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
mbShow = False
End Sub

Regards,
Peter T


"EXCELMACROS" <(E-Mail Removed)> wrote in message
news:8DDCE026-32F0-4639-812F-(E-Mail Removed)...
> Hello, me again.., I'm trying to close a msgbox using application.ontime
> now
> + 5seg
>
> Thank you in advance
> --
> Thank you...



 
Reply With Quote
 
Orion Cochrane
Guest
Posts: n/a
 
      30th Dec 2008
Set a reference to Windows Script Host Object Model (Tools > References).
Copy and paste the TimedMsgBox code and try it. It works for me.
--
I am running on Office 2003, unless otherwise stated.


"EXCELMACROS" wrote:

> Sorry Leith, it did not work. I have to click "OK" for it to close...
> --
> Thank you...
>
>
> "Leith Ross" wrote:
>
> >
> > Hello EXCELMACROS,
> >
> > Here is macro to close the dialog after 5 seconds. You can change this
> > to suite your needs.
> >
> > Code:
> > --------------------
> >
> > Sub TimedMsgBox()
> >
> > Dim Msg As String
> > Dim Secs As Long
> > Dim Wsh As Object
> >
> > Title = "Test"
> > Msg = "This will close in 5 seconds."
> > Secs = 5
> >
> > Set Wsh = CreateObject("WScript.Shell")
> > RetVal = Wsh.Popup(Msg, Secs, Title, vbInformation + vbOKOnly)
> > Set Wsh = Nothing
> >
> > End Sub
> >
> > --------------------
> >
> > Sincerely,
> > Leith Ross
> >
> >
> > --
> > Leith Ross
> > ------------------------------------------------------------------------
> > Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
> > View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=45231
> >
> >

 
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
close msgbox =?Utf-8?B?RGFu?= Microsoft Excel Programming 4 30th Jul 2007 07:40 PM
Close a msgbox =?Utf-8?B?RnJhbmsgQw==?= Microsoft Access VBA Modules 4 20th Jun 2005 07:49 PM
Close Msgbox =?Utf-8?B?QWxleA==?= Microsoft Access Form Coding 3 2nd May 2005 08:53 PM
Close MsgBox dbl Microsoft Access Reports 3 24th Mar 2005 07:53 PM
Close a MsgBox Taffy Microsoft Excel Programming 6 4th Oct 2004 09:39 PM


Features
 

Advertising
 

Newsgroups
 


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