Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default What kind of workbook function should I used?

I would like to save and close excel file after not active for 15 mins, to
define not being active is shown below:
1) not page up / down action
2) not switching any worksheet by clicking it
....
When the file is automatically opened based on schedule, I used to read this
report, as I sit in front of PC, I will read it and close it manually, but as
I am not available, and there is no action for this workbook, then I prefer
to save and close after 15 mins. However, I might open two workbooks at the
same time, so not being active only apply to this workbook only, since I
might click and reading another workbook at the same time. I get no idea on
which workbook function can perform this task, does anyone have any
suggestions?
Thanks in advance for any suggestions
Eric
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default What kind of workbook function should I used?

Chip Pearson helped me with something similar just yesterday. Here's what I
ended up doing . . .

In VBA, go to the Tools menu, choose References, and then Windows Script
Host Object Model.

(This code goes behind the sheet)
Public CloseDownTime As Variant

Public Sub ResetTimer()
On Error Resume Next
If Not IsEmpty(CloseDownTime) Then Application.OnTime
EarliestTime:=CloseDownTime, Procedu="CloseDownFile", Schedule:=False
CloseDownTime = Now + TimeValue("00:00:10") ' hh:mm:ss
Application.OnTime CloseDownTime, "CloseDownFile"
End Sub

Public Sub CloseDownFile()
On Error Resume Next

Dim R As VbMsgBoxResult
With New IWshRuntimeLibrary.WshShell
R = .Popup("Click 'Yes' if you would like another 10 seconds... If
the 'Yes' button is not clicked Excel will save your work and close the file
in 10 seconds.", 2, , vbYesNo + vbDefaultButton2)
End With

If R = vbYes Then
' user clicked yes
Call ResetTimer
Else
' user clicked no
Application.StatusBar = "Inactive File Closed: " &
ThisWorkbook.Name
ThisWorkbook.Close SaveChanges:=True
End If
End Sub

(This code goes in ThisWorkbook Module)
Option Explicit

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
ResetTimer
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
ResetTimer
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
ResetTimer
End Sub

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Eric" wrote:

I would like to save and close excel file after not active for 15 mins, to
define not being active is shown below:
1) not page up / down action
2) not switching any worksheet by clicking it
...
When the file is automatically opened based on schedule, I used to read this
report, as I sit in front of PC, I will read it and close it manually, but as
I am not available, and there is no action for this workbook, then I prefer
to save and close after 15 mins. However, I might open two workbooks at the
same time, so not being active only apply to this workbook only, since I
might click and reading another workbook at the same time. I get no idea on
which workbook function can perform this task, does anyone have any
suggestions?
Thanks in advance for any suggestions
Eric

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
Looking for a function that performs a special kind of Vlookup Ayo Excel Discussion (Misc queries) 4 January 20th 10 12:06 AM
Some kind of Array-Sumproduct Function ryguy7272 Excel Worksheet Functions 18 January 24th 09 04:02 AM
?? Some kind of look up function - Help and Thanks A Lot! TJehn Excel Worksheet Functions 2 November 10th 08 12:07 AM
can i make a "repeat until" kind of function in excel2003 JMMendez Excel Discussion (Misc queries) 1 July 9th 06 07:36 PM
Is there any onLoad kind of function for Excel sameerce Excel Programming 2 April 9th 04 10:03 AM


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