找答案的高端用户(找答案钻石及双钻级别的用户)将尽可能从此问题下的所有回
答中,为您推荐最佳答案。届时您可以根据推荐数采纳答案。
如果自提问时间起7天内您仍无法选出最佳答案,您可以选择“无满意答案”关闭此问题。
Dim ExcelApp
Dim ExcelBook
Dim ExcelSheet
Dim i ''用于检查哪一行未写入数据
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("C:\tmpProj\Model.xlsx") Then
''模板文件存在
If fso.FileExists("C:\tmpProj\1.xlsx") Then
''今天生成的文件存在
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelBook = ExcelApp.Workbooks.Open("C:\tmpProj\1.xlsx")
Set ExcelSheet = ExcelBook.Sheets.Item("Sheet1")
''判断第几行为空
i = 2 ''起始行为2
Do While ExcelSheet.Cells(i,2).Value <> ""
i = i + 1
Loop
ExcelSheet.Cells(i, 2).Value = SmartTags("VarUnsigned8")
ExcelBook.Save
ExcelBook.Close
ExcelApp.Quit
Set ExcelBook = Nothing
Set ExcelApp = Nothing
Else
''今天生成的文件不存在
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelBook = ExcelApp.Workbooks.Open("C:\tmpProj\Model.xlsx")
Set ExcelSheet = ExcelBook.Sheets.Item("Sheet1")
ExcelSheet.Cells(2, 2).Value = SmartTags("VarUnsigned8")
ExcelBook.Saveas "C:\tmpProj\1.xlsx"
ExcelBook.Close
ExcelApp.Quit
Set ExcelBook = Nothing
Set ExcelApp = Nothing
End If
Else
''模板文件不存在
MsgBox "模板文件不存在!"
End If
首次回答问题,获得
双倍西币积分!
立即成为技术知识分享的一员!
找答案微信小程序
提问
搜索
欢迎您访问支持中心!
丰富的视频,全方位的文档,大量的网友交流精华……
为了更好的完善这些内容,我们诚邀您在浏览结束后,花20秒左右的时间,完成一个用户在线调查!
感谢您的支持!