我有一个 VBScript,可以打开一个文件夹中的任何 XML 文件并将它们作为 excel 文件保存到另一个文件夹。
它似乎有效,虽然生成的 excel 文件没有 XLS 扩展名,但有什么想法吗?
然后我希望脚本做的是从源文件夹中删除所有文件。我该怎么做?
Dim xlApp, xlWkb, SourceFolder,TargetFolder,file
Set xlApp = CreateObject("excel.application")
set fs = CreateObject("Scripting.FileSystemObject")
Const xlNormal=1
SourceFolder="c:\test\xml"
TargetFolder="c:\test\xls"
'Hide Excel
xlApp.Visible = false
'Process each file in SourceFolder
for each file in fs.GetFolder(SourceFolder).files
'Open file in SourceFolder
Set xlWkb = xlApp.Workbooks.Open(file)
'Get Filename
BaseName= fs.getbasename(file)
'Concatenate full path. Extension will be automatically added by Excel
FullTargetPath=TargetFolder & "\" & BaseName
'Save as XLS file into TargetFolder
xlWkb.SaveAs FullTargetPath, xlNormal
'Close file
xlWkb.close
next
Set xlWkb = Nothing
Set xlApp = Nothing
Set fs = Nothing