Help with Auto Save

Rocky0201

Active Member
Joined
Aug 20, 2009
Messages
278
Hi..

I'm trying to Auto Save my workbook every 60 seconds. I have the following code in ThisWorkbook. When the code pops off the timer, I get a message displayed Cannot run the macro "C:\... shows the path with the path ending in !TheSub. The macro may not be available in the workbook or all marcos may be disabled."

Code:
Private Sub Workbook_Open()
    Call StartTimer
End Sub
Sub StartTimer()
    RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
    Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
        Schedule:=True
End Sub
Sub TheSub()
    ''''''''''''''''''''''''
    ActiveWorkbook.Save
    MsgBox "Master Schedule Saved"
    ''''''''''''''''''''''''
    StartTimer  ' Reschedule the procedure
End Sub
The following is in a Module:

Code:
Public RunWhen As Double
Public Const cRunIntervalSeconds = 60 ' 1 minute
Public Const cRunWhat = "TheSub"  ' the name of the procedure to run

Do I not have the subs setup properly? My Marcos are enabled.

Thanks for the help.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi..

I'm trying to Auto Save my workbook every 60 seconds. I have the following code in ThisWorkbook. When the code pops off the timer, I get a message displayed Cannot run the macro "C:\... shows the path with the path ending in !TheSub. The macro may not be available in the workbook or all marcos may be disabled."


Do I not have the subs setup properly? My Marcos are enabled.

Thanks for the help.

Move this to your module as well.
Code:
Sub StartTimer()
    RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
    Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
        Schedule:=True
End Sub
Sub TheSub()
    ''''''''''''''''''''''''
    ActiveWorkbook.Save
    MsgBox "Master Schedule Saved"
    ''''''''''''''''''''''''
    StartTimer  ' Reschedule the procedure
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,506
Messages
6,125,189
Members
449,213
Latest member
Kirbito

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top