run time error:5 invalid procedure call

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vickyanusha
    New Member
    • Jun 2014
    • 1

    run time error:5 invalid procedure call

    I tried to run a batch file using shell command. my code is as below. it throws an error run time error:5, invalid procedure call and on debut it points out the shell command line. pl clarify and solve the problem.

    My code to run the batch file.

    Code:
    Dim path As String
    path = ActiveWorkbook.path
    Dim retVal, A, fs
    Dim coln As String
    coln = Mid(path, 1, 1)
     
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set A = fs.CreateTextFile(path & "\" & "merge.bat", True)
    A.writeline "@echo off"
    A.writeline coln & ":"
    A.writeline "cd " & path & "\"
    A.writeline "del tdslist.txt"
    A.writeline "del tdsrefund.txt"
    A.writeline "copy *.txt tds.txt"
    A.Close
    retVal = Shell(path & "\" & "merge.bat", 1)
    merge.bat file is created but don't run thro shell command. if i double click the batch file it rund perfectly
    pl help

    R Ravisankar
    Last edited by Rabbit; Jun 17 '14, 05:16 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Luk3r
    Contributor
    • Jan 2014
    • 300

    #2
    Does your path have a space in the name? If so you'd have to double quote your path.

    Comment

    • meditation
      New Member
      • Jun 2014
      • 13

      #3
      Does merge.bat runs fine from command prompt?

      Comment

      Working...