Код:
Option Explicit
Dim objExcel
Dim strSourceFileSystemObject
Dim objFile
If WScript.Arguments.Count > 0 Then
With WScript.CreateObject("Scripting.FileSystemObject")
Set objExcel = Nothing
For Each strSourceFileSystemObject In WScript.Arguments
If .FolderExists(strSourceFileSystemObject) Then
For Each objFile In .GetFolder(strSourceFileSystemObject).Files
WorkingWithWorkbook objFile, .GetExtensionName(objFile.Name)
Next
ElseIf .FileExists(strSourceFileSystemObject) Then
WorkingWithWorkbook .GetFile(strSourceFileSystemObject), .GetExtensionName(strSourceFileSystemObject)
Else
WScript.Echo "Can't find source file or source folder [" & strSourceFileSystemObject & "]."
End If
Next
If Not objExcel Is Nothing Then
objExcel.Quit
Set objExcel = Nothing
End If
End With
Else
WScript.Echo "Usage: cscript.exe //nologo """ & WScript.ScriptName & """ <Source file or source folder> [<Source file or source folder> [...]]"
WScript.Quit 1
End If
WScript.Quit 0
'=============================================================================
'=============================================================================
Sub WorkingWithWorkbook(objExcel, objFile)
WScript.Echo objFile.Path
With objExcel
With .Workbooks.Open(objFile.Path)
With .Worksheets(1).Range("A4:I4")
.Replace "02.07.2015", "09.07.2015"
End With
.Save
.Close
End With
End With
End Sub
'=============================================================================