Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default auto close while MsgBox is open

My code includes the following.

Dim Message, Title, Response
Message = "Entry must be numeric."
Title = "Invalid Entry"
Response = MsgBox(Message, Style, Title, Help, Ctxt)

and, in a separate module,

Sub Auto_Open()
' bunch of code
Application.OnTime Now + TimeValue("00:00:30"), "Close_Workbook"
' more code
End Sub
Sub Close_Workbook()
Application.DisplayAlerts = False
ThisWorkbook.Close
End Sub

I want to guard against someone walking away without responding with an "OK" to the message.
Is there a way I can get the workbook to automatically close while the MsgBox is still open?

Thanks in advance.


Kevin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default auto close while MsgBox is open

Jim Rech cited a self closing msgbox if you have the windows scripting host:

From: "Jim Rech"
References: <024001c23a01$584dfec0$37ef2ecf@TKMSFTNGXA13
<e2XDD2hOCHA.1728@tkmsftngp12 <OUq7WIhPCHA.496@tkmsftngp09
<##np6ohPCHA.2624@tkmsftngp13 <OHr91qiPCHA.1996@tkmsftngp12
Subject: MsgBox without asking user to click <OK
Date: Wed, 7 Aug 2002 13:50:39 -0400
Lines: 15
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1079
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1079
Message-ID: <#ghpFrjPCHA.2048@tkmsftngp08
Newsgroups: microsoft.public.excel.programming
NNTP-Posting-Host: 199.207.253.101


No, you do not need a reference when you use CreateObject. You are running
this from Excel rather than the VBE? The only time I had a problem was when
I started it from the VBE and switched to Excel while it was running.

Sub SelfClosingMsgBox()
Dim wsh As Object
Set wsh = CreateObject("WScript.Shell")
wsh.Popup "Hello!", 2, "This closes itself in 2 seconds"
End Sub

--
Jim Rech
Excel MVP
----------------------------
Some people responsed that it didn't close for them. I didn't have any
problem with it.

Tested in xl97 SR2, windows 98 SE
xl2000, Windows 2000
xl2000, Windows XP Pro (although it seemed to hang around
longer than 2 seconds)
--
Regards,
Tom Ogilvy

Kevin wrote in message
...
My code includes the following.

Dim Message, Title, Response
Message = "Entry must be numeric."
Title = "Invalid Entry"
Response = MsgBox(Message, Style, Title, Help, Ctxt)

and, in a separate module,

Sub Auto_Open()
' bunch of code
Application.OnTime Now + TimeValue("00:00:30"), "Close_Workbook"
' more code
End Sub
Sub Close_Workbook()
Application.DisplayAlerts = False
ThisWorkbook.Close
End Sub

I want to guard against someone walking away without responding with an

"OK" to the message.
Is there a way I can get the workbook to automatically close while the

MsgBox is still open?

Thanks in advance.


Kevin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default auto close while MsgBox is open

You've come through again Tom. It works just fine.

Thanks much.


Kevin

----- Tom Ogilvy wrote: -----

Jim Rech cited a self closing msgbox if you have the windows scripting host:

From: "Jim Rech"
References: <024001c23a01$584dfec0$37ef2ecf@TKMSFTNGXA13<e2XD @tkmsftng 6@tkmsftngp12
Subject: MsgBox without asking user to click <OK
Date: Wed, 7 Aug 2002 13:50:39 -0400
Lines: 15
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1079
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1079
Message-ID: <#ghpFrjPCHA.2048@tkmsftngp08
Newsgroups: microsoft.public.excel.programming
NNTP-Posting-Host: 199.207.253.101


No, you do not need a reference when you use CreateObject. You are running
this from Excel rather than the VBE? The only time I had a problem was when
I started it from the VBE and switched to Excel while it was running.

Sub SelfClosingMsgBox()
Dim wsh As Object
Set wsh = CreateObject("WScript.Shell")
wsh.Popup "Hello!", 2, "This closes itself in 2 seconds"
End Sub

--
Jim Rech
Excel MVP
----------------------------
Some people responsed that it didn't close for them. I didn't have any
problem with it.

Tested in xl97 SR2, windows 98 SE
xl2000, Windows 2000
xl2000, Windows XP Pro (although it seemed to hang around
longer than 2 seconds)
--
Regards,
Tom Ogilvy

Kevin wrote in message
...
My code includes the following.
Dim Message, Title, Response

Message = "Entry must be numeric."
Title = "Invalid Entry"
Response = MsgBox(Message, Style, Title, Help, Ctxt)
and, in a separate module,
Sub Auto_Open()

' bunch of code
Application.OnTime Now + TimeValue("00:00:30"), "Close_Workbook"
' more code
End Sub
Sub Close_Workbook()
Application.DisplayAlerts = False
ThisWorkbook.Close
End Sub
I want to guard against someone walking away without responding with an

"OK" to the message.
Is there a way I can get the workbook to automatically close while the

MsgBox is still open?
Thanks in advance.
Kevin




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
code to close an excel sheet without saving it .(via msgbox) Satyam Reddy Excel Worksheet Functions 2 May 14th 08 02:48 PM
Clear Auto Filter on Close (or open) Karin Excel Discussion (Misc queries) 3 August 23rd 07 06:16 PM
Auto filter using msgbox in macro not woking ashish128 Excel Discussion (Misc queries) 4 June 9th 07 06:08 AM
Auto Open, Refresh, Save, Close Jimmycooker Excel Discussion (Misc queries) 0 February 6th 06 01:34 PM
Novice - MsgBox Yes/No - Continue if Yes, Close if No Beetlejuice Excel Discussion (Misc queries) 6 August 29th 05 09:48 PM


All times are GMT +1. The time now is 05:39 AM.

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

About Us

"It's about Microsoft Excel"