I need to run multiple .vbs at a time. This is the only way I was able to find online:
Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "1.vbs"
objShell.Run "2.vbs"
objShell.Run "3.vbs"
Set objShell = Nothing
To do that I'd have create 1.vbs, 2.vbs and 3.vbs separately. Is there a way to input them all as part of one .vbs file? Something like
Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
Dim vbs1 as vbscript
Dim vbs2 as vbscript
Dim vbs3 as vbscript
Set vbs1 =
"Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'C:\Users\test1.xlsm'!Module1.refresh"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing"
Set vbs2 = ' whatever code
Set vbs3 = ' whatever code
objShell.Run vbs1
objShell.Run vbs2
objShell.Run vbs3
Set objShell = Nothing
The purpose of this:
- I have ~50 excel reports with connections to SQL that need to be updated every day.
- To do that I've created a macro and added it to each of them. The macro refreshes connections/queries > refreshes pivot tables > removes the connections/queries > saves as a macro-free workbook in a specified location.
- I wrote .vbs scripts for each report. It just runs that macro in every Excel workbook.
- Instead of running every .vbs separately, I've created one main .vbs that references all prior created .vbs to run them at the same time.
- My question is if there's a way to do that without creating 50 separate .vbs files.