恭喜,你发布的帖子
发布于 2022-11-13 17:37:00
5楼
Sub OnLButtonDown(Byval Item, Byval Flags, Byval x, Byval y)
Dim S1,S2
Dim filename
Dim filename1
Dim oExcel
Dim UD_1,UD_2,UD_3,UD_4,UD_5,UD_6,UD_7,UD_8,UD_9,UD_10,UD_11,UD_12,UD_13
Dim UD_14,UD_15,UD_16,UD_17,UD_18,U_1,U_2,U_3,WWW,QQQ
Dim TTT
Dim ID_USER
Set S1=HMIRuntime.Tags("T0")
'Set S2=HMIRuntime.Tags("TT0")
Set filename=HMIRuntime.Tags("FN")
Set UD_1 = HMIRuntime.Tags("Ud1")
Set UD_2 = HMIRuntime.Tags("Ud2")
Set UD_3 = HMIRuntime.Tags("Ud3")
Set UD_4 = HMIRuntime.Tags("Ud4")
Set UD_5 = HMIRuntime.Tags("Ud5")
Set UD_6 = HMIRuntime.Tags("Ud6")
Set UD_7 = HMIRuntime.Tags("Ud7")
Set UD_8 = HMIRuntime.Tags("Ud8")
Set UD_9 = HMIRuntime.Tags("Ud9")
Set UD_10 = HMIRuntime.Tags("Ud10")
Set UD_11 = HMIRuntime.Tags("Ud11")
Set UD_12 = HMIRuntime.Tags("Ud12")
Set UD_13 = HMIRuntime.Tags("Ud13")
Set UD_14 = HMIRuntime.Tags("Ud14")
Set UD_15 = HMIRuntime.Tags("Ud15")
Set UD_16 = HMIRuntime.Tags("Ud16")
Set UD_17 = HMIRuntime.Tags("Ud17")
Set UD_18 = HMIRuntime.Tags("Ud18")
Set U_1 = HMIRuntime.Tags("U1")
Set U_2 = HMIRuntime.Tags("U2")
Set U_3 = HMIRuntime.Tags("U3")
Set WWW = HMIRuntime.Tags ("W_A")
Set TTT = HMIRuntime.Tags ("t")
Set QQQ = HMIRuntime.Tags ("Q")
Set ID_USER = HMIRuntime.Tags ("ID")
S1.Value = NoW
S1.Write
'文件
filename.Value=Replace(Replace(Replace( NoW(),"/",""),":","")," ","")
'Msgbox(FILENAME)
filename.Write
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Add
oExcel.Visible = 0
'UD_1.value = HMIRuntime.Tags ("REAL_UD1")
'oExcel.CELLS(1,1) = UD_1.READ
'oExcel.CELLS(1,2) = UD_2.READ
'oExcel.CELLS(1,3) = UD_3.READ
'oExcel.CELLS(1,4) = UD_4.READ
'oExcel.CELLS(1,5) = UD_5.READ
'oExcel.CELLS(1,6) = UD_6.READ
'oExcel.CELLS(1,7) = UD_7.READ
'oExcel.CELLS(1,8) = UD_8.READ
'oExcel.CELLS(1,9) = UD_9.READ
'oExcel.CELLS(1,10) = UD_10.READ
'oExcel.CELLS(1,11) = UD_11.READ
'oExcel.CELLS(1,12) = UD_12.READ
'oExcel.CELLS(1,13) = UD_13.READ
'oExcel.CELLS(1,14) = UD_14.READ
'oExcel.CELLS(1,15) = UD_15.READ
'oExcel.CELLS(1,16) = UD_16.READ
'oExcel.CELLS(1,17) = UD_17.READ
'oExcel.CELLS(1,18) = UD_18.READ
oExcel.CELLS(1,1) = "初值U1"
oExcel.CELLS(1,2) = "终值U2"
oExcel.CELLS(1,3) = "样值U3"
oExcel.CELLS(1,4) = "氦气量W"
oExcel.CELLS(1,5) = "时间t"
oExcel.CELLS(1,6) = "总漏率Q"
oExcel.CELLS(1,7) = "试验员"
oExcel.CELLS(2,1) = U_1.READ
oExcel.CELLS(2,2) = U_2.READ
oExcel.CELLS(2,3) = U_3.READ
oExcel.CELLS(2,4) = WWW.READ
oExcel.CELLS(2,5) = TTT.READ
oExcel.CELLS(2,6) = QQQ.READ
oExcel.CELLS(2,7) = ID_USER.READ
'oExcel.CELLS(3,1) = S2.Read
'MsgBOX UD_1.read
oExcel.ActiveWorkbook.SaveAs "D:\" & filename.value &".xlsx"
oExcel.Quit
End Sub
这个是写excel文件的。
请填写推广理由:
分享
只看
楼主