- Set fso=CreateObject("Scripting.FileSystemObject")
- text=fso.OpenTextFile("模板.vbs", 1).ReadAll
- fd = fso.GetFolder(".").Path
- Set objExcel = CreateObject("Excel.Application")
- Set objBook = objExcel.Workbooks.open(fd&"\OLT设备表11.xlsx")
- objBook.worksheets(1).activate
- Set objSheet = objBook.activeSheet
- rows=objSheet.usedrange.rows.count
- For i=2 To rows '从第2行开始遍历
- result=""
- caption=objSheet.Cells(i, 2).value 'B列
- ip=objSheet.Cells(i, 3).value 'C列
- filename=objSheet.Cells(i, 4).value 'D列
- result=replace(replace(text, "Hostname", ip), "Func", caption)
- msgbox result
- 'fso.CreateTextFile(filename, 2).Write(result)
- Next
- objBook.Close
- objExcel.Quit
复制代码
|