Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. Timed Auto Save Macro?
  2.  
  3. eddy said:
  4. Jul 21st, 2002 10:31 AM
  5. Default
  6. Is it possible to have an "auto run" macro which runs as soon as the workbook is opened, and then auto save the workbook every "x" mins. into the original path (without getting any dialogs e.g save as, yes/no boxes)? The workbook must always remain open.
  7. All help appreciated.
  8. eD
  9.  
  10. Timed Auto Save Macro?
  11.  
  12. Tom Schreiner said:
  13. Jul 21st, 2002 10:48 AM
  14. Default
  15. Hi Ted.
  16. Copy this into any standard module:
  17.  
  18.  
  19. Option Explicit
  20.  
  21. Public RunTime
  22.  
  23.  
  24.  
  25. Sub StartTimer()
  26.  
  27. RunTime = Now + #12:10:00 AM#
  28.  
  29. Application.OnTime RunTime, "SaveBook", schedule:=True
  30.  
  31. End Sub
  32.  
  33.  
  34.  
  35.  
  36.  
  37. Sub SaveBook()
  38.  
  39. ActiveWorkbook.Save
  40.  
  41. StartTimer
  42.  
  43. End Sub
  44.  
  45.  
  46.  
  47.  
  48.  
  49. Sub StopTimer()
  50.  
  51. On Error Resume Next
  52.  
  53. Application.OnTime RunTime, "SaveBook", schedule:=False
  54.  
  55. End Sub
  56.  
  57.  
  58.  
  59.  
  60.  
  61. Place this in your workbook class module:
  62.  
  63.  
  64. Private Sub Workbook_Open()
  65.  
  66. StartTimer
  67.  
  68. End Sub
  69.  
  70.  
  71.  
  72. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  73.  
  74. StopTimer
  75.  
  76. End Sub
  77.  
  78.  
  79.  
  80.  
  81.  
  82. This will save your workbook every 10 minutes without interupting you.
  83. Tom
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement