提前感谢您的帮助。 我正在运行VbScript(下面的代码)来编辑.csv文件并将其另存为另一个文件,但是,我不断收到以下错误:
行:30个字符:1错误:另存为Workbook类的方法失败代码:800A03EC
Dim xlApp, xlWkb, xlSh, SourceFolder, TargetFolder, file
Dim str, strClean
Dim cell
Set xlApp = CreateObject("excel.application")
Set fs = CreateObject("Scripting.FileSystemObject")
SourceFolder="I:\Documents\Rajarshi_SVN Repositorywc\Global Fund Services - Long Funds\02_Funds STP\02_Funds STP Phase 1\03_Test scripts\04_Test data\CSV - Chk"
TargetFolder="I:\Documents\Rajarshi_SVN Repositorywc\Global Fund Services - Long Funds\02_Funds STP\02_Funds STP Phase 1\03_Test scripts\04_Test data\CSV - New"
xlApp.visible = false
For Each file in fs.GetFolder(SourceFolder).files
Set xlWkb = xlApp.Workbooks.Open(file)
BaseName = fs.getbasename(file)
Set xlSh = xlWkb.Worksheets(1)
For Each cell in xlSh.Range("A2:XFD2")
With CreateObject("vbscript.regexp")
.Pattern = "[\/[0-9a-zA-Z]*\/]*"
.Global = True
cell = .Replace(cell, vbNullString)
End With
Next
FullTargetPath=TargetFolder & "\" & BaseName & ".csv"
xlWkb.SaveAs FullTargetPath, xlCSV, , , , , , 2
xlWkb.Saved = True
xlWkb.Close
Set xlSh = Nothing
Set xlWkb = Nothing
Next
Set xlApp = Nothing
Set fs = Nothing
MsgBox "XML Files headers converted successfully"
即使我能够简单地保存文件,我也没关系。