It worked perfectly!! Thanks.
I had to take the msgbox out as I didn't want it telling me anything, just not doing anything if it failed to update.
Although it's lead me to another question.
A different excel file I have lifts data from some third party software and then saves periodically. I've just got that saving periodically on a timer.
Since it's saving to a network file, sometimes it thinks someone else has it open (even when they don't) and it'll throw a fit and stop doing anything.
Again, what I want to happen, is if the file save fails for any reason, for it to just skip and go to the next line.
Here's the code I've got - Start_Counter is run when I open the file, Stop_counter is run on file close.
Public RunWhen As Double
Public Const cRunIntervalSeconds = 300 ' five minute counter
Public Const cRunWhat = "Save_File" ' Save file macro
Sub Start_Counter()
'Start counter as soon as file is opened, but only if opened read/write.
'Every time the timer finishes, the file will save.
If ActiveWorkbook.ReadOnly Then
Else
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
End If
'So Excel won't ask to save when I close the file
ThisWorkbook.Saved = True
End Sub
Sub Save_File()
'
' Save File, then restart timer.
'
ThisWorkbook.Save
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
'
End Sub
Sub Stop_Counter()
'Cancel timer on file close.
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=False
End Sub