jtbrown1955
New Member
- Joined
- Jan 12, 2005
- Messages
- 40
I have a timer set to close a workbook automatically after it has been left open on a network and is no longer active. The second copy opened (of course) is a read only. When the read only book closes it prompts the user "There is already a file with that name, do you want to save over that file?" If the user says yes, it WILL overwrite the file. This is a "read only copy". Without the following code, the read only copy will act normal and won't allow you to save over the file. Here is the code that I got off this forum. Thanks! I need something added to it, to tame the read only copy.
This is under ThisWorkbook
Private Sub Workbook_Open()
Reset
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Reset
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Reset
End Sub
This is under Module1
Sub Reset()
Static SchedSave
If SchedSave <> 0 Then
Application.OnTime SchedSave, "SaveWork", , False
End If
SchedSave = Now + TimeValue("00:10:00") ' 10 minutes
Application.OnTime SchedSave, "SaveWork", , True
End Sub
Sub SaveWork()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub
Thanks
Jim
This is under ThisWorkbook
Private Sub Workbook_Open()
Reset
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Reset
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Reset
End Sub
This is under Module1
Sub Reset()
Static SchedSave
If SchedSave <> 0 Then
Application.OnTime SchedSave, "SaveWork", , False
End If
SchedSave = Now + TimeValue("00:10:00") ' 10 minutes
Application.OnTime SchedSave, "SaveWork", , True
End Sub
Sub SaveWork()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub
Thanks
Jim