I'm trying to create and run a VBScript to run a macro I've created (PVT_Paste_Macro.xlsm) on Excel files without opening each individual Excel file (I have 528 files!) Here is my code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'C:\Users\Owner\Desktop\PVT_Paste_Macro.xlsm'!Module1.PVT_Paste_Macro"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing
After running the code, I get the following error:
Script: C:\Users\Owner\Desktop\VBA for macros - PVT.vbs
Line: 2
Char: 1
Error: Unknown runtime error
Code: 800A03EC
Source: Microsoft VBScript runtime error
I run the script while the macro file is open. The macro file, the (test) Excel file I'd like to run the macro on, and the VBS script are all located on the Desktop.
Can anyone help? Thanks.