Vinit,
Here is an RSView VBA program. It logs 10 tags once a minute, creates a new Excel file once a day at midnight (12:00 PM), using the date and time in the file name, and saves in a sub-directory called "HOT_GAS_LOG". Perhaps this can be used as an example and guide, for you to modify to suit your needs.
Public Sub WriteCSVLogFile()
Dim AIT240 As Tag
Dim F3 As Tag
Dim F5 As Tag
Dim FE171 As Tag
Dim FE172 As Tag
Dim FE256 As Tag
Dim FE257 As Tag
Dim FUELLOGTOTAL As Tag
Dim PDT240 As Tag
Dim RECIPE_START As Tag
Dim SYSTEMRUN As Tag
Dim TE142 As Tag
Dim TE171 As Tag
Dim TE200 As Tag
Dim TE210 As Tag
Dim TE108 As Tag
Dim LogDate As Date
Dim LogFile As Integer
Dim HeaderTrack As Integer
Dim HeaderPrint As Integer
On Error GoTo catch
MkDir ("C:\HOT_GAS_LOG")
Check:
'Check to see if the header needs to be inserted.
'HeaderTrack is an Integer bit that is set to 0 if it is 12:00 AM, otherwise set = 1.
If ((Format$(Time, "hh:mm:ss") >= #12:00:00 AM#) And (Format$(Time, "hh:mm:ss") <= #12:01:00 AM#)) Or (HeaderPrint = 0) Then
HeaderTrack = 1
Else: HeaderTrack = 0
End If
Set AIT240 = gProject.TagDb("AIT240_SCALED")
Set F3 = gProject.TagDb("F3_RUNNING")
Set F5 = gProject.TagDb("F5_RUNNING")
Set FE171 = gProject.TagDb("FE171_SCALED")
Set FE172 = gProject.TagDb("FE172_SCALED")
Set FE256 = gProject.TagDb("FE256_SCALED")
Set FE257 = gProject.TagDb("FE257_SCALED")
Set FUELLOGTOTAL = gProject.TagDb("FUELLOG_TOTAL")
Set PDT240 = gProject.TagDb("PIC240_PV_SCALED")
Set RECIPESTART = gProject.TagDb("RECIPE_START_PB")
Set SYSTEMRUN = gProject.TagDb("SYSTEM_RUN")
Set TE142 = gProject.TagDb("TE_142")
Set TE171 = gProject.TagDb("TE171_SCALED")
Set TE200 = gProject.TagDb("TE200_AVERAGE")
Set TE210 = gProject.TagDb("TE_210")
Set TE108 = gProject.TagDb("TIC108_PV_SCALED")
'Set LogDate equal to current date function.
LogDate = Date
'Get available file number
LogFile = FreeFile
'Open File for writing to and name file with format date.csv
Open "C:\HOT_GAS_LOG\" & Format$(LogDate, "mmddyy") & ".csv" For Append As #LogFile
'Insert the Header into the csv file between 12:00 and 12:01 AM (or next time program runs) and then insert the data in the correct columns.
If HeaderTrack = 1 Then
Print #LogFile, " TIME"; ","; _
"AIT-240_NOX"; ","; _
"F-3_FAN_ON/OFF"; ","; _
"F-5_FAN_ON/OFF"; ","; _
"FE-171 STACK FLOW"; ","; _
"FE-172 FUEL FLOW"; ","; _
"FE-256 SUPPLY DUCT FLOW"; ","; _
"FE-257 RETURN DUCT FLOW"; ","; _
"TOTAL FUEL USED"; ","; _
"PDT-240 PRESSURE"; ","; _
"RECIPE ON/OFF"; ","; _
"SYSTEM_ON/OFF"; ","; _
"TE-142 TEMP"; ","; _
"TE-171 STACK TEMP"; ","; _
"CHAMBER TEMP"; ","; _
"TE-210 TEMP"; ","; _
"TE-108 TEMP"; ","
'Insert data into column if the header was just inserted
Print #LogFile, Format$(Time, "hh:mm:ss"); ","; _
Format(AIT240.Value, "###0"); ","; _
Format(F3.Value, "#0"); ","; _
Format(F5.Value, "#0"); ","; _
Format(FE171.Value, "####0.0"); ","; _
Format(FE172.Value, "#0.0"); ","; _
Format(FE256.Value, "###0.0"); ","; _
Format(FE257.Value, "###0.0"); ","; _
Format(FUELLOGTOTAL.Value, "#######0"); ","; _
Format(PDT240.Value, "0.00"); ","; _
Format(RECIPESTART.Value, "#0"); ","; _
Format(SYSTEMRUN.Value, "#0"); ","; _
Format(TE142.Value, "###0"); ","; _
Format(TE171.Value, "###0"); ","; _
Format(TE200.Value, "###0"); ","; _
Format(TE210.Value, "###0"); ","; _
Format(TE108.Value, "###0"); ","
HeaderPrint = 1
Else
'If time is anything other than 12:00 and 12:01 midnight just insert the data
Print #LogFile, Format$(Time, "hh:mm:ss"); ","; _
Format(AIT240.Value, "###0"); ","; _
Format(F3.Value, "#0"); ","; _
Format(F5.Value, "#0"); ","; _
Format(FE171.Value, "####0.0"); ","; _
Format(FE172.Value, "#0.0"); ","; _
Format(FE256.Value, "###0.0"); ","; _
Format(FE257.Value, "###0.0"); ","; _
Format(FUELLOGTOTAL.Value, "#######0"); ","; _
Format(PDT240.Value, "0.00"); ","; _
Format(RECIPESTART.Value, "#0"); ","; _
Format(SYSTEMRUN.Value, "#0"); ","; _
Format(TE142.Value, "###0"); ","; _
Format(TE171.Value, "###0"); ","; _
Format(TE200.Value, "###0"); ","; _
Format(TE210.Value, "###0"); ","; _
Format(TE108.Value, "###0"); ","
End If
Close #LogFile
'If the directory already exists, skip to the next line
'Error 75 is directory already created or exists.
catch: 'Error handling routine
If Err.Number = 75 Then
Err.Clear
GoTo Check
Else:
If Err.Number = 4170 Then
Print "Error#4170--Communications driver is not available."
'roErrorTagEvent (4170) - an error occurred while waiting for the operation to complete
Err.Clear
GoTo Check
End If 'End errror #4170
Err.Clear
End If 'End errror handling
End Sub