I am trying to run this code VB code but it giving me error which is mentioned below.
Any help will greatly appreciated as I am new to 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
command :cscript c:\macro\test.vbs
Result: error , line 2 , char 38 , expected ')'