Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Within excel I run a macro at regular intervals.
I use the following line as part of the macro to run a batch file:
Call Shell(Environ$("COMSPEC") & " /c C:\Temp\autoftp.bat", vbNormalFocus)

All this does is open an ftp connection, call the .dat file to populate the required information, upload and close.

Is there any way of running the batch file without the DOS Shell popping up on the screen to run the file?

It is only there for a second or so but it is annoying and distracting.

1 solution

Use vbHide instead of vbNormalFocus
So try the below one
Call Shell(Environ$("COMSPEC") & " /c C:\Temp\autoftp.bat", vbHide)

Visual Basic for Applications Reference - Shell function[^]
Share this answer
Dalek Dave 4-Feb-12 14:32pm    
Thanks, that seems to have done it for me!

I owe you, two answers to my dim-witted questions :)
thatraja 5-Feb-12 12:02pm    
Welcome. BTW don't know who down-voted your question. Have my counter.
Espen Harlinn 9-Feb-12 10:00am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900