资源描述:
《excel报表不写数据.》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、excel报表不写数据. 目的:想在每天的14:50:00清除数据(先提前打开报表,清除一下数据),然后在15:00,16:00,17:00分别往表格里写数据(触发周期为:30分钟)。当在17:00写完数据后,以当天的日期为名称另存一份。运行后并不往表格里写数据,请帮忙分析一下程序. OptionExplicit Functionaction DimobjExcelApp,objExcelBook,objExcelSheet OnErrorResumeNext DimExcelApp,ExcelB
2、ook SetExcelApp=GetObject(,”Excel.Application”) IfTypeName(ExcelApp)=“Application”Then ForEachExcelBookInExcelApp.WorkBooks IfExcelBook.FullName=“E:empeeexcel报表不写数据. 目的:想在每天的14:50:00清除数据(先提前打开报表,清除一下数据),然后在15:00,16:00,17:00分别往表格里写数据(触发周期为:30分钟)。当在17:00写完
3、数据后,以当天的日期为名称另存一份。运行后并不往表格里写数据,请帮忙分析一下程序. OptionExplicit Functionaction DimobjExcelApp,objExcelBook,objExcelSheet OnErrorResumeNext DimExcelApp,ExcelBook SetExcelApp=GetObject(,”Excel.Application”) IfTypeName(ExcelApp)=“Application”Then ForEachExcel
4、BookInExcelApp.WorkBooks IfExcelBook.FullName=“E:empeeiao.xls”Then ExcelApp.ActiveWorkbook.Save ExcelApp.Workbooks.Close ExcelApp.Quit SetExcelApp=Nothing ExitFor EndIf Next EndIf SetobjExcelApp=CreateObject(“Excel.Application”) IfHour(Now)=14AndM
5、inute(Now)=50AndSecond(Now)=0Then objExcelApp.Visible=True objExcelApp.Workbooks.Open”E:empeeiao.xls” objExcelApp.Cells(5,1).Value=Null objExcelApp.Cells(5,2).Value=Null objExcelApp.Cells(5,3).Value=Null objExcelApp.Cells(6,1).Value=Null objExcelApp.C
6、ells(6,2).Value=Null objExcelApp.Cells(6,3).Value=Null objExcelApp.Cells(7,1).Value=Null objExcelApp.Cells(7,2).Value=Null objExcelApp.Cells(7,3).Value=Null objExcelApp.Workbooks.Close objExcelApp.Quit SetobjExcelApp=Nothing EndIf IfHour(Now)=15AndMi
7、nute(Now)=0AndSecond(Now)=0Then objExcelApp.Visible=True objExcelApp.Workbooks.Open”E:empeeiao.xls” objExcelApp.Cells(5,1).Value=Now objExcelApp.Cells(5,2).Value=HMIRuntime.Tags(“aa2”).read objExcelApp.Cells(5,3).value=HMIRuntime.Tags(“aa3”).read objEx
8、celApp.ActiveWorkbook.Save objExcelApp.Workbooks.Close objExcelApp.Quit SetobjExcelApp=Nothing ”MsgBox”10” ElseIfHour(Now)=16AndMinute(Now)=00AndSecond(Now)=0Then objExcelApp.Visibl