Hi,
I have the following vba macro:
I have a VBS script that call the above macro:
The code works seamlessly. However, one of the the computers I work on, when I run the VBS script to run the VBA macro, the codes to run till it encounters error on the following line:
I've been looking at it but I couldn't figure out why that line of code creates problem.
Error message: Run-time error '9':
Subscript out of range
I have the following vba macro:
Code:
Sub save_Report()Set fso = CreateObject("Scripting.FileSystemObject")
basePath = "C:\Users\Orders"
pathName = basePath & "\" & thisYear & "\" & month_Name & "\" & get_FolderDate(minus_day)
fileName_Order_Stats = get_Order_Stats_filename(minus_day)
Workbooks("Order_Template").SaveAs pathName_Order_Stats & "\" & fileName_Order_Stats & ".xlsm", FileFormat:=52
End Sub
I have a VBS script that call the above macro:
Code:
Set objExcel = CreateObject("Excel.Application")
Set wb = objExcel.Application.Workbooks.Open("C:\Users\Template\Order_Template.xlsm")
objExcel.Application.Run "'" & wb.Name & "'!save_Report"
wb.Save
wb.Close
Set wb = Nothing
The code works seamlessly. However, one of the the computers I work on, when I run the VBS script to run the VBA macro, the codes to run till it encounters error on the following line:
Code:
Workbooks("Order_Template").SaveAs pathName_Order_Stats & "\" & fileName_Order_Stats & ".xlsm", FileFormat:=52
I've been looking at it but I couldn't figure out why that line of code creates problem.
Error message: Run-time error '9':
Subscript out of range