用excel打开模板文件,存文件的问题。
我用下面的代码,打开模板文件时,就不能正常打开。没有了反应。木板文件的日期会变,其他语句不变,用workbooks.add,就可以。
肯定有读写权限。
大家帮我看看多谢!
Dim xlWorkSheet ' Excel Worksheet object
Dim xlApplication
Set xlApplication = CreateObject("Excel.application")
xlApplication.Visible = False
template="c:\InetPub\wwwroot\bao\temp.xls"
xlApplication.Workbooks.Open(template)
Set xlWorksheet = xlApplication.Worksheets(1)
xlWorksheet.Cells(2,1).Value = "Year1"
xlWorksheet.Cells(2,2).Value = "Region1"
xlWorksheet.Cells(2,3).Value = "Sales1"
strFile = "testexc"
xlWorksheet.SaveAs Server.MapPath(".") & "\bao\" & strFile & ".xls"
xlApplication.Quit ' Close the Workbook
Set xlWorksheet = Nothing
Set xlApplication = Nothing