如何从文件夹转换xml文件并通过VBscript保存到不同文件夹中的xls?

时间:2013-10-04 12:23:14

标签: excel vbscript

我正在运行此脚本,但在Targetfolder中没有任何内容,没有文件。关于如何解决这个问题的任何想法?

感谢您的时间!

Dim xlApp, xlWkb, SourceFolder, TargetFolder, file
Set xlApp = CreateObject("excel.application")
Set fs = CreateObject("Scripting.FileSystemObject")
Const xlNormal = 1
SourceFolder = "c:\temp\XMLfiles"
TargetFolder = "c:\temp\XLSfiles"

'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

MsgBox "Finished. Have a nice day!"

1 个答案:

答案 0 :(得分:0)

将脚本放入扩展名为“.vbs”

的文本文件中