Announcement

Collapse
No announcement yet.

Shell Command In Vba

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shell Command In Vba

    Hi ,

    I have to run command prompt from with my VBA code , and run an application passing it 2 filenames and redirecting the output of the application to a third file. Also my VBA script should wait for the application to complete running before getting back to the next line of execution. HEre is what i have coded so far :

    Code:
    Sub Macro1()
    
    Dim dosCmd As String
    
    dosCmd = "purge.exe  input1.txt input2.txt >> opFile.txt"
    
    Call Shell("cmd.exe " & dosCmd, vbNormalFocus)
    Now this code ends up just opening the command prompt and nothing else. It does not run purge.exe. Can someone guide me on this please ?

  • #2
    Re: Shell Command In Vba

    I use to execute an external file that populates files; once the final file is created it continues with everything else...

    Code:
    Sub ScriptExport()
      Dim RetVal
        RetVal = Shell("J:\AcctMgt\3N\WFM\Scripting\Scripts\AuxReports\AuxReports.bat", 1)
      Call ScriptExportDone
    End Sub
    Sub ScriptExportDone()
      Do Until Dir("J:\AcctMgt\3N\WFM\Scripting\Scripts\AuxReports\QWT\QWTBOYCEaux.xls") <> "": Loop
      Call cchr
    End Sub

    Comment


    • #3
      Re: Shell Command In Vba

      when i try to use Shell it does not compile , i have to use call shell . Would anyone know why this is the case ?

      Comment


      • #4
        ??

        Comment

        Working...
        X