Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default VBA code to automatically close file

Does VBA code exist to automatically close a file after a
specified period of time?

Thanks.


Kevin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default VBA code to automatically close file

Kevin,

In a regular module, try the following:

Sub Auto_Open()
' Following line will call "CloseMe" in 1 minute
Application.OnTime Now + TimeValue("00:01:00"), "CloseMe"
End Sub

Sub CloseMe()
' If you want to save it before closing
ThisWorkbook.Save
' To quit Excel altogether
Application.Quit
' To just close the workbook and leave Excel open
ThisWorkbook.Close
End Sub

John

Kevin wrote:

Does VBA code exist to automatically close a file after a
specified period of time?

Thanks.

Kevin


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default VBA code to automatically close file

Thanks John.

I did get this code to work with it configured
for "Application.Quit". However, gefore the file is
closed a message box prompts "Do you want to save the
changes you made to ...?"

How can I get the file to auto close/quit without issuing
this message?

Thanks.

Kevin

-----Original Message-----
Kevin,

In a regular module, try the following:

Sub Auto_Open()
' Following line will call "CloseMe" in 1 minute
Application.OnTime Now + TimeValue("00:01:00"), "CloseMe"
End Sub

Sub CloseMe()
' If you want to save it before closing
ThisWorkbook.Save
' To quit Excel altogether
Application.Quit
' To just close the workbook and leave Excel open
ThisWorkbook.Close
End Sub

John

Kevin wrote:

Does VBA code exist to automatically close a file after

a
specified period of time?

Thanks.

Kevin


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default VBA code to automatically close file

Kevin,

Two ways.........
Just before that code to quit

Application.DisplayAlerts = False

or......
fool the workbook into thinking it's already saved

ThisWorkbook.Saved = True
(just before the Quit coding)

John

Kevin wrote:

Thanks John.

I did get this code to work with it configured
for "Application.Quit". However, gefore the file is
closed a message box prompts "Do you want to save the
changes you made to ...?"

How can I get the file to auto close/quit without issuing
this message?

Thanks.

Kevin

-----Original Message-----
Kevin,

In a regular module, try the following:

Sub Auto_Open()
' Following line will call "CloseMe" in 1 minute
Application.OnTime Now + TimeValue("00:01:00"), "CloseMe"
End Sub

Sub CloseMe()
' If you want to save it before closing
ThisWorkbook.Save
' To quit Excel altogether
Application.Quit
' To just close the workbook and leave Excel open
ThisWorkbook.Close
End Sub

John

Kevin wrote:

Does VBA code exist to automatically close a file after

a
specified period of time?

Thanks.

Kevin


.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default VBA code to automatically close file

Thanks much John.

You have been a great help.

Kevin
-----Original Message-----
Kevin,

Two ways.........
Just before that code to quit

Application.DisplayAlerts = False

or......
fool the workbook into thinking it's already saved

ThisWorkbook.Saved = True
(just before the Quit coding)

John

Kevin wrote:

Thanks John.

I did get this code to work with it configured
for "Application.Quit". However, gefore the file is
closed a message box prompts "Do you want to save the
changes you made to ...?"

How can I get the file to auto close/quit without

issuing
this message?

Thanks.

Kevin

-----Original Message-----
Kevin,

In a regular module, try the following:

Sub Auto_Open()
' Following line will call "CloseMe" in 1 minute
Application.OnTime Now + TimeValue

("00:01:00"), "CloseMe"
End Sub

Sub CloseMe()
' If you want to save it before closing
ThisWorkbook.Save
' To quit Excel altogether
Application.Quit
' To just close the workbook and leave Excel open
ThisWorkbook.Close
End Sub

John

Kevin wrote:

Does VBA code exist to automatically close a file

after
a
specified period of time?

Thanks.

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
File/Close automatically saving changes without prompt Joe@SAA Excel Discussion (Misc queries) 0 June 23rd 08 10:31 PM
Copy from another file and close automatically Jim G Excel Discussion (Misc queries) 2 October 17th 07 01:31 AM
How to code the Macro to save and close a file? Eric Excel Discussion (Misc queries) 7 June 10th 07 03:28 PM
close form code tkaplan Excel Discussion (Misc queries) 1 June 3rd 05 10:49 PM
Close worksheet with Macro or Code sanaullah Excel Programming 1 October 2nd 03 08:35 PM


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