VBA Shell and Wait

jgspencer

New Member
Joined
Apr 3, 2009
Messages
35
I need help with some code regarding shell and wait. I am trying to write a shell that triggers a .exe file and regrinds hours in the POS system that my restaurants use. I need to have the startdate equal the cell in Sheet 1 Cell A1 and then go back to Monday and stop before Sunday. A few things I am having trouble with:

-How do I set the startdate to equal that cell and format the start date to "yyyyddmm" and run the .exe file to loop from startdate to Monday and stop before Sunday.
-If the file does not exist, how do I handle the error so the loop continues.
-Also, I need it to also incorporate a shell and wait that will not continue to the next step of code until the shell has finished but to stop running after 3 minutes if the shell does not complete the task.

I have read about the shell and wait function but I don't really understand it that much. Here is what I have so far even though it's not much:

Sub GndHours()

On Error GoTo GndErr

Dim RetVal
RetVal = Shell("C:\aloha\bin\grind.exe /date yyyyddmm")

ExitHere:
Exit Sub

GndErr:
Select Case Err.Number
Case Else
Resume ExitHere
End Select
End Sub

Your help will be much appreciated.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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