Suppose you want to save every 5 minutes.
1. Type "Save Period" in cell A4 and "0:5:00" in cell B4 (without quotes)
2. Open Module1 to add a counter in RTNest or RTNow whichever you are using.
In the top section after Dim, where Public variables are declared, add this line-
Code:
Public SP as date ' Variable SP stores Save Period
3. Find the Timer() subroutine and replace it with this-
Code:
Private Sub Timer()
If TimerActive = True Then
On Error Resume Next
If TimeValue(Now()) >= Range("L4").Value Then
MyBook.Sheets("Nest").Range("D4") = "Time is- " & Now() & " Exchange closed"
ElseIf TimeValue(Now()) <= Range("L3").Value Then
MyBook.Sheets("Nest").Range("D4") = "Time is- " & Now() & " Exchange not open yet"
Else
MyBook.Sheets("Nest").Range("D4") = Now()
' New Code for saving database at fixed interval
If SP > Range("B4") Then
SP = #0:00:00# ' This part of code may have to be changed
AB.SaveDatabase
Else
SP = SP + RP
End If
MakeCSV 'Calls Subroutine for generating csv file
If DBPath <> "" Then CallAmiBroker 'Calls AmiBroker for importing file
End If
4. I have not tested this code. You will have to do some R&D