Use VBA to run/terminate Shell command and save file

Carno

New Member
Joined
May 18, 2019
Messages
3
Greetings! I have a shell command that uses curl to capture live audio output from a port on our call server.


Code:
Sub RecordAudio()


Call Shell("cmd.exe /S /K" & "curl 92.68.0.10:8888 > i:\voicetemp\voice.wav", vbMinimizedFocus) 


End Sub

What I would like to know is; 1) how can I stop the recording (close the shell window) using VBA and, 2) how can I append a date/time stamp to the file?


Currently, when I run the macro, it opens a shell window and executes the command just fine. The file continues recording until I close the shell window. I would like to give the user a button that will close the shell window for them and timestamp the recording. ex. "voice_2019-05-20 1019.wav"


Any help greatly appreciated!


PS I realize the shell command can be executed without using cmd - so there is no shell window - but I've had even less luck with that. At least with the shell window I can close it and stop the recording. When I run it without cmd, it just records forever until I kill the process. Happy to try any/all suggestions!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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