Good morning happy campers,
I have the following codes:
Module 1
Public Wb As Workbook
Public RunWhen As Date
Public RunWhat As String
Public Executed As Boolean
Public Sub GetSavesStarted()
Set Wb = ThisWorkbook
RunWhat = "SaveThis"
Executed = True
Call SaveThis
End Sub
Public Sub SaveThis()
Application.DisplayAlerts = False
Wb.UpdateLink Name:=Wb.LinkSources
Application.DisplayAlerts = True
RunWhen = Now + TimeValue("00:00:05")
Application.OnTime EarliestTime:=RunWhen, Procedure:=RunWhat, _
Schedule:=True
End Sub
This Workbook -
Private Sub WorkBook_Open()
Call GetSavesStarted
End Sub
Private Sub WorkBook_BeforeClose(Cancel As Boolean)
If Executed = True Then Application.OnTime EarliestTime:=RunWhen, Procedure:=RunWhat, _
Schedule:=False
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Call GetSavesStarted
End Sub
For the most part, all the codes work fine, in short they refresh the values on the sheet every 5 seconds, triggered by opening the workbook AND when a change is made to the workbook.
However, at times i get a run time error - 'Method "UpdateLink' of Object '_Workbook' failed
highlighting the following in yellow (from Module1)
Wb.UpdateLink Name:=Wb.LinkSources
Could anyone please shed some light for me please?
Kind regards.
Bookmarks