Dim objExcelApp,objExcelbook,objExcelSheet
Dim fn,count,sheetname,t
Dim n,y,r
Dim a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11
If HMIRuntime.Tags("BC_CZ8_Start").Read = 1 Then HMIRuntime.Tags("CZG8.TIMESTART").Write Now End If
HMIRuntime.Tags("CZG8.CZG").Write "称重罐8"
HMIRuntime.Tags("CZG8.PF").Write HMIRuntime.Tags("PH_PH_CZ8").Read
If HMIRuntime.Tags("BC_CZ8_Start").Read = 0 And HMIRuntime.Tags("BC_CZ8_Aborted").Read = 0 Then
HMIRuntime.Tags("CZG8.TIMESTOP").Write Now
HMIRuntime.Tags("CZG8.ZL").Write HMIRuntime.Tags("WT04W201DB_OUT").Read
HMIRuntime.Tags("CZG8.FL").Write HMIRuntime.Tags("JY_FULIAO_CZ8_WT_SJ").Read
If HMIRuntime.Tags("JY_GTJ_CZ8_SP_WT").Read > 0 Then
HMIRuntime.Tags("CZG8.GTJ").Write HMIRuntime.Tags("JY_GTJ_CZ8_WT_SJ").Read
Else
HMIRuntime.Tags("CZG8.GTJ").Write 0
End If
If HMIRuntime.Tags("JY_TS_CZ8_SP_WT").Read > 0 Then
HMIRuntime.Tags("CZG8.TS").Write HMIRuntime.Tags("JY_TS_CZ8_WT_SJ").Read
Else
HMIRuntime.Tags("CZG8.TS").Write 0
End If
If HMIRuntime.Tags("JY_MYT_CZ8_SP_WT").Read > 0 Then
HMIRuntime.Tags("CZG8.MYT").Write HMIRuntime.Tags("JY_MYT_CZ8_WT_SJ").Read
Else
HMIRuntime.Tags("CZG8.MYT").Write 0
End If
If HMIRuntime.Tags("JY_RO_CZ8_SP_WT").Read > 0 Then
HMIRuntime.Tags("CZG8.RO").Write HMIRuntime.Tags("JY_RO_CZ8_WT_SJ").Read
Else
HMIRuntime.Tags("CZG8.RO").Write 0
End If
If HMIRuntime.Tags("JY_GUOLI_CZ8_SP_WT").Read > 0 Then
HMIRuntime.Tags("CZG8.GL").Write HMIRuntime.Tags("JY_GUOLI_CZ8_WT_SJ").Read
Else
HMIRuntime.Tags("CZG8.GL").Write 0
End If
End If
If HMIRuntime.Tags("BC_CZ8_Start").Read = 0 And HMIRuntime.Tags("BC_CZ8_Aborted").Read = 0 Then
n=CStr(Year(Now))
If Month(Now)<10 Then
y="0"&CStr(Month(Now))
Else
y=CStr(Month(Now))
End If
If Day(Now)<10 Then
r="0"&CStr(Day(Now))
Else
r=CStr(Day(Now))
End If
fn=n&y&r
Set a1=HMIRuntime.Tags("CZG8.CZG")
Set a2=HMIRuntime.Tags("CZG8.PF")
Set a3=HMIRuntime.Tags("CZG8.TIMESTART")
Set a4=HMIRuntime.Tags("CZG8.TIMESTOP")
Set a5=HMIRuntime.Tags("CZG8.ZL")
Set a6=HMIRuntime.Tags("CZG8.GL")
Set a7=HMIRuntime.Tags("CZG8.GTJ")
Set a8=HMIRuntime.Tags("CZG8.MYT")
Set a9=HMIRuntime.Tags("CZG8.TS")
Set a10=HMIRuntime.Tags("CZG8.RO")
Set a11=HMIRuntime.Tags("CZG8.FL")
count=HMIRuntime.Tags("BBDB_COUNT_CZ").Read
t=count+1
sheetname="Sheet1"
Set objExcelApp=CreateObject("Excel.Application")
objExcelApp.visible=FalSE
objExcelApp.workbooks.open "E:\BB\CZ.xlsx"
objExcelApp.worksheets(sheetname).activate
objExcelApp.worksheets(sheetname).cells(t,1).value=fn
a1.Read
objExcelApp.worksheets(sheetname).cells(t,2).value=a1.Value
a2.Read
objExcelApp.worksheets(sheetname).cells(t,3).value=a2.Value
a3.Read
objExcelApp.worksheets(sheetname).cells(t,4).value=a3.Value
a4.Read
objExcelApp.worksheets(sheetname).cells(t,5).value=a4.Value
a5.Read
objExcelApp.worksheets(sheetname).cells(t,6).value=a5.Value
a6.Read
objExcelApp.worksheets(sheetname).cells(t,7).value=a6.Value
a7.Read
objExcelApp.worksheets(sheetname).cells(t,8).value=a7.Value
a8.Read
objExcelApp.worksheets(sheetname).cells(t,9).value=a8.Value
a9.Read
objExcelApp.worksheets(sheetname).cells(t,10).value=a9.Value
a10.Read
objExcelApp.worksheets(sheetname).cells(t,11).value=a10.Value
a11.Read
objExcelApp.worksheets(sheetname).cells(t,12).value=a11.Value
objExcelApp.ActiveWorkbook.Save
objExcelApp.ActiveWorkbook.close
objExcelApp.ActiveWorkbook.Quit
Set objExcelApp=Nothing
sunrtnj@163.com