用VB脚本写变量到 excel的程序如下:
Dim linecount
Dim numbercount
Sub writeexcel( )
Dim fso,myfile,daystr,dstr,fname,dtime
Dim ObjExcelApp
Dim readtime
Dim readdate
linecount=linecount+1
numbercount=1
dstr = FormatDateTime(Date)
dtime= FormatDateTime(Time)
fname="d:\" + dstr + ".xls"
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Workbooks.Open fname
objExcelApp.worksheets("sheet1").Cells(linecount, 1).VAlue = " " + dtime +" "
objExcelApp.worksheets("sheet1").Cells(linecount, 2).VAlue = "1234"
objExcelApp.ActiveWorkbook.Save
objExcelApp.Workbooks.ClosE
objExcelApp.QuiT
Set ObjEXceLapp = Nothing
End Sub
Sub newexcelfile()
Dim fso,myfile,daystr,dstr,fname
dstr = FormatDateTime(Date)
fname="d:\" + dstr + ".xls"
Set fso = CreateObject("s cripting.FileSystemObject")
Set MyFile = fso.GetFile("d:\ExcelExample.xls")
MyFile.Copy (fname)
End Sub
程序可以写数到EXCEL中, 建立新文件也可以,动作用定时器触发.
现在现场工艺不能用定时器触发,要求采集的温度到达一定值触发动作,或给个布尔量用上升沿触发动作.不知该怎么做.各位帮忙.