May 26th, 2022

VBA 2010 – 063: Shell Command

The Shell Command allows you to open up and run files on your computer, In this example we use it to run a batch file.

Download the samples for this series for free!

All our tutorial samples are free however if you appreciate our work and would like to make a voluntary donation then please do.

Recommended Reading

Both the below books by John Walkenbach are fantastic books and he is a brilliant author, I would recommend picking one of these books up even if just for a reference. I have read power programming cover to cover and it is easy to follow and is a must have for any serious VBA programmer.

If you have read any books and feel they are worth recommending then please post about them on our Forum.

VBA 2010 – 062: Emails with Attachments

VBA 2010 – 064: SendKeys


  1. Sean Casey
    May 28, 2014

    Hi Matt, when I try to pass the parameter %1, the Shell window no longer stays open on the screen. It flashes up and disappears very fast. Everything I have done is like for like. Any ideas as why this could be happening?


    Sean (casey67)

    • Matthew
      June 6, 2014

      Have you got the PAUSE Batch command at the end of your batch code. Otherwise it will just run and then close?

      • June 21, 2014

        Yeah got the pause command at the end of code. Tried deleting and then adding back but it’s still not having any of it.

        Any other suggestions?

  2. June 22, 2014

    …I am trying all these on VBA 2007 and a laptop running Vista Basic. Would this affect it perhaps?

    • Matthew
      June 23, 2014

      do you want to paste your batch code in the comments so I can run it myself?

  3. June 24, 2014

    Its the same code as yours Matt:

    echo %1


Leave a comment

Your email address will not be published. Required fields are marked *