VBA to trigger multiple batch files not working

McG_84

New Member
Joined
Nov 28, 2016
Messages
11
Hey everyone. I have code to trigger 6 different batch files, which then outputs a txt file, which in turn i use power query to bring the txt file list into excel. I thought it was working fine until one day I noticed the date stamp on the txt file had not changed in a week, despite running the batch file. I ran the batch file by double clicking it a sure enough the txt file updated. I was then able to just use the "refresh all" option in excel to get the file list updates (this batch file simply goes into each folder and returns whatever files have a certain extension). My question is, what is going on here? The batch file comes on my screen and I see it doing its thing, then the next, and then the next but none of the files update. Anyone encounter this odd behavior before? Summarized code below:

Code:
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1
Dim MyPath As String
Dim MyShellCMD As String
MyShellCMD = """" & MyPath & "\" & "FileList.bat" & """"
wsh.Run MyShellCMD , windowStyle, waitOnReturn
ThisWorkbook.Connections("Query - FirstFolder").Refresh
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,214,523
Messages
6,120,033
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top