move to next vba command after the batch file finishes BUT with the cmd window open RRS feed

  • Question

  • All,

    I was able to use CreateObject("") for shelland wait.

    But the prolem is that it look slike it is mandatory to close the cmd/dos window to move to the next step in vba. As my cmd window will contain important information, I would like to move to next vba command after bacth processing is complete but move to next command with dos window still open.

    Thanks in advance 

    Thursday, April 10, 2014 6:02 PM

All replies

  • can you paste the code ? Both VBA and Batch.

    If confidential, pls put only relevant portion and replace with dummy code.

    Best Regards,
    Asadulla Javed, Kolkata
    Please do not forget to click “Vote as Helpful” if any post helps you and "Mark as Answer”if it solves the issue.

    Friday, April 11, 2014 12:39 PM
  • Hi Ashish,

    Welcome to post in MSDN forums.

    It seems that you need a way to call the shell window asyncrously in VBA code.

    1. By default the Shell function will run the batch file asyncrously.

    Shell ("D:\cleaner.bat")

    Waiting for Completion

    By default, the Shell function runs the program asynchronously. This means that a program that starts with the Shell function might not finish executing before the statements that follow the Shell function execute. If you want to wait for the program to finish before you continue, set Wait to True.

    2. Or you could try call Exec function instead of Run function of the shell object.

    Differences between Run and Exec (VBScript)

    But I'm not sure if this method will work, please give it a shot.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Edited by Caillen Wednesday, April 16, 2014 9:59 AM
    Wednesday, April 16, 2014 9:57 AM