我正在尝试运行此代码 VB 代码,但它给了我下面提到的错误。
任何帮助将不胜感激,因为我是 VB 的新手。
**Code :**
Option Explicit
Public Sub ReadExcelFiles(FolderName As String)
Dim FileName As String
' Add trailing \ character if necessary
'
If Right(FolderName, 1) <> "\" Then FolderName = FolderName & "\"
FileName = Dir(FolderName & "*.xls")
Do While FileName <> ""
Workbooks.Open (FolderName & FileName)
Sub Macro1()
'
' Macro1 Macro
'
'
Range("A1").Select
ActiveCell.FormulaR1C1 = "Name"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Anil"
Range("A2").Select
End Sub
Workbooks(FileName).Close
FileName = Dir()
Loop
End Sub
Public Sub test()
ReadExcelFiles ("C:\Macro")
End Sub
命令:cscript c:\macro\test.vbs
结果:错误,第 2 行,字符 38,预期 ')'