Dim objXL Dim wsSheet '-- The full path to the template file must be provided in the command line '-- level eg c:\Temp\_excel> npfmacro.vbs c:\temp\_excel\npftemplate.xlsm '-- where the npfmacro.vbs is located in the directory c:\temp\_excel '-- the npftemplate.xlsm has a macro in the module called npf_errorasses which is '-- looking for a file called batch.xlsx to act upon. On Error Resume Next If WScript.Arguments.Count = 1 Then Set objXL = CreateObject("Excel.Application") With objXL .Workbooks.Open (WScript.Arguments.Item(0)) Set wsSheet = objXL.ActiveWorkbook.Worksheets(2) On Error GoTo 0 If IsObject(wsSheet) Then .Application.Run "npf_errorasses" Else .Application.Run "npf_errorasses" End If .Application.Quit End With Set objXL = Nothing END If