Vba 在vb脚本中自动覆盖文件

Vba 在vb脚本中自动覆盖文件,vba,excel,vbscript,Vba,Excel,Vbscript,我正在使用一个vb脚本(写在下面)从一个.xls文件中创建两个.csv文件。由于这必须通过算法在迭代过程中使用,我想知道是否有机会自动覆盖生成的两个文件。现在我必须手动确认每个覆盖。代码不是我的,因为我是这方面的新手,非常感谢 if WScript.Arguments.Count < 2 Then WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv Sourc

我正在使用一个vb脚本(写在下面)从一个.xls文件中创建两个.csv文件。由于这必须通过算法在迭代过程中使用,我想知道是否有机会自动覆盖生成的两个文件。现在我必须手动确认每个覆盖。代码不是我的,因为我是这方面的新手,非常感谢

if WScript.Arguments.Count < 2 Then
WScript.Echo "Error! Please specify the source path and the destination.    Usage: XlsToCsv SourcePath.xlsx Destination.csv"
Wscript.Quit
End If
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))  
Dim WS1
Set WS1 = oBook.WorkSheets.item("Base Reactions")
WS1.Activate
oBook.SaveAs WScript.Arguments.Item(1), 6
Dim WS2
Set WS2 = oBook.WorkSheets.item("Steel Sum - AISC 360-10")
WS2.Activate
oBook.SaveAs WScript.Arguments.Item(2), 6
oBook.Close true
oExcel.Quit
如果WScript.Arguments.Count<2,则
WScript.Echo“错误!请指定源路径和目标。用法:XlsToCsv SourcePath.xlsx destination.csv”
Wscript.Quit
如果结束
暗色oExcel
设置oExcel=CreateObject(“Excel.Application”)
Dim oBook
设置oBook=oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
昏暗的WS1
设置WS1=oBook.WorkSheets.item(“基本反应”)
WS1.激活
oBook.SaveAs WScript.Arguments.Item(1),6
昏暗的WS2
设置WS2=oBook.工作表.项目(“钢总量-AISC 360-10”)
WS2.激活
oBook.SaveAs WScript.Arguments.Item(2),6
好的,接近真值
oExcel,退出
从对象浏览器(Alt+F11、F2,搜索另存为)

按F1键以获取帮助

ConflictResolution   Optional XlSaveConflictResolution.
XlSaveConflictResolution可以是这些XlSaveConflictResolution常量之一

xlUserResolution  (display the conflict-resolution dialog box) 
xlLocalSessionChanges (automatically accept the local user's changes) 
xlOtherSessionChanges  (accept other changes instead of the local user's changes) 

如果省略此参数,将显示冲突解决对话框。

这不是VB.NET代码。请使用正确的标记:Vba、VBScript、excel Vba etcIf您使用的
Application.DisplayAlerts=False
它将禁用您正在覆盖文件的警报。
xlUserResolution  (display the conflict-resolution dialog box) 
xlLocalSessionChanges (automatically accept the local user's changes) 
xlOtherSessionChanges  (accept other changes instead of the local user's changes)