Consulting

Results 1 to 4 of 4

Thread: Run Autoit File from Excel File Location

  1. #1
    VBAX Regular
    Joined
    Jun 2012
    Posts
    45
    Location

    Run Autoit File from Excel File Location

    I am using this code and it gives me
    Run time Error 5
    Invalid Procedure or Argument

    when I change last line to

    runscript = Shell("FileName", 1)

    It gives Run time Error 53
    What am I doing wrong

    [VBA]
    Sub RunFileName()
    Dim runscript
    Dim FileName As String
    FileName = ThisWorkbook.Path & "\AutoitCode.au3"
    MsgBox (FileName)
    runscript = Shell(FileName, 1)
    End Sub
    [/VBA]

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    AutoitCode.au3 does not look like an executable file. If it's not, VBA willl give a run time error 5.

    You can try Adding the executable that runs *.au3 files to the path name. This line assume that AutoIt.exe is in the System Path

    [VBA]FileName = "AutoIt3.exe " & ThisWorkbook.Path & "\AutoitCode.au3"[/VBA]

    Note the space after AutoIt.exe

    If it's not, you'll have to find its path and
    [VBA]Dim AutoItPath
    AutoItPath = "Path to Executable" & "\AutoIt.exe "
    runscript = Shell(AotuItPath &FileName, 1)[/VBA]
    Note the space after AutoIt.exe
    Last edited by SamT; 04-21-2013 at 05:58 PM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    You might want to use DIR() to see if the files exists first, otherwise:[vba]Sub RunFileName()
    Dim
    runscript
    Dim
    FileName As String FileName = ThisWorkbook.Path & "\AutoitCode.au3"
    MsgBox (FileName)
    runscript = Shell("cmd /c " & """" & FileName & """", 1)
    End Sub
    [/vba]

    Of course if AutoIt is not installed, it will fail as well. There are ways to find that out if needed.

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You could also try FollowHyperlink
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •