Dim objExcelApp,a,RCP,ID,objOffice
Dim COUNT,CR,i,HR,MNT,SCND,Dt,Tm
Dim fso,DY,MNTH,YR
Dim a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a15
HR=Hour(Time())
MNT=Minute(Time())
SCND=Second(Time())
DY = Day(Date())
MNTH = Month(Date())
YR = Year(Date())
Dt = DY & "_" & MNTH & "_" & YR
Tm = HR & "_" & MNT
a = HMIRuntime.Tags("FLOW_ROW").Read
On Error Resume Next
Set objOffice = GetObject(,"Excel.Application")
objExcelApp.DisplayAlerts = False
objOffice.ActiveWorkbook.Save
objExcelApp.DisplayAlerts = False
objOffice.Workbooks.Close
objExcelApp.DisplayAlerts = False
objOffice.quit
Set objOffice = Nothing
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = False
objExcelApp.Workbooks.Open "D:\REPORT\DAILY_FLOW.xlsx"
objExcelApp.DisplayAlerts = False
objExcelApp.Cells(a,1).Value =Date()
objExcelApp.Cells(a,2).Value =Time()
objExcelApp.Cells(a,6).Value = 0.5*a
objExcelApp.Cells(a,7).Value = 1*a
objExcelApp.Cells(a,8).Value = 2*a
objExcelApp.Cells(a,9).Value = 3*a
objExcelApp.Cells(a,10).Value = 4*a
objExcelApp.Cells(a,11).Value = 5*a
objExcelApp.Cells(a,12).Value = 6*a
objExcelApp.Cells(a,13).Value = 7*a
objExcelApp.Cells(a,14).Value = 8*a
objExcelApp.Cells(a,15).Value = 9*a
objExcelApp.Cells(a,16).Value = 10*a
objExcelApp.Cells(a,17).Value = 11*a
objExcelApp.ActiveWorkbook.Save
objExcelApp.DisplayAlerts = False
objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp = Nothing
If a=0 Or a=1 Then
a=4
HMIRuntime.Tags("FLOW_ROW").Write a
Else
a=a+1
HMIRuntime.Tags("FLOW_ROW").Write a
End If
I am using this code for entry in excel file. It is checking if any excel is open. If it is then it closes the excel first, without any prompt and then opens the excel, without visibility and make entry and then closes the excel again. All without any display alerts.
Problem I am facing is, sometimes a row is skipped between two entries. I am trying to find in what case it can happen?
Kbv.