答案1
我不会把整个过程写出来,因为我不知道你的文件或结构是什么样的。你所要做的就是将 excel 表信息加载到代码中并让循环运行。它会将每一行添加到批处理文件中。你可以添加一个 shell 来自动运行它……但如果你这样做,你可能需要稍作停顿或延迟。
Sub Blah()
Dim fso As Scripting.FileSystemObject
Dim F As File
Dim F2 As TextStream
Dim BatchFile As String
'Also, need to load in excel stuff up here.
BatchFile = ("C:\Users\" & Environ$("Username") & "\Documents\FileName.bat")
Set F2 = fso.CreateTextFile("C:\Users\" & Environ$("Username") & "\Documents\FileName.bat")
RowNum = 1
On Error GoTo Errs:
S = ""
Do Until Worksheet.Cells(RowNum, 1).value = ""
S = S & workshee.Cells(RowNum, 1) & Chr(13) & Chr(10)
RowNum = RowNum + 1
Loop
Errs:
F2.Write S
End Sub