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
我正在使用此代码输入excel文件。它正在检查是否有任何excel是开放的。如果是,那么它首先关闭excel,没有任何提示然后打开excel,没有可见性并进入,然后再次关闭excel。全部没有任何显示警报。
我面临的问题是,有时在两个条目之间会跳过一行。我试图找到它会发生什么情况?
KBV。