+ Reply to Thread
Results 1 to 6 of 6

Shell Sub Fault

  1. #1
    Forum Contributor
    Join Date
    12-20-2006
    Posts
    127

    Shell Sub Fault

    The below seems to throw up an error for me

    run time error 5
    invalid procedure call or argument


    Sub Test_Refresh()
    Shell "C:\Plasma\ACD_Refresh.acsauto", 4
    End Sub

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Jtwork,

    The Shell funtion in VBA can only open executable application files. If you are wanting to open the file in your example, you can use the ShellExecute API. This will only open the file if the file extension is registered. Here is a macro that uses the ShellExecute API function...

    Please Login or Register  to view this content.
    Using your file as an example:
    OpenFile("C:\Plasma\", "ACD_Refresh", ".acsauto")

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    12-20-2006
    Posts
    127

    Thanks

    Thank you for your help, ive copy and pasted the code into a separate module but im not sure how to execute it.

  4. #4
    Forum Contributor
    Join Date
    12-20-2006
    Posts
    127

    Hmm

    Ive tried running the function like so in the same and diff module's but i get the following error after entering the openfile function

    Compile error:
    Expected: =


    Sub testthisone()
    OpenFile("C:\Plasma\", "ACD_Refresh", ".acsauto")
    End Sub

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Jtwork,

    Sorry about the lack of calling explanation. Your Sub should look like this...

    Please Login or Register  to view this content.
    The OpenFile function returns TRUE if the file opened successfully, otherwise it returns FALSE. OpenFile will display an error message if the file fails to open correctly, but without a return value the procedure that called OpenFile has no way of knowing if an error did occur.

    Sincerely,
    Leith Ross

  6. #6
    Forum Contributor
    Join Date
    12-20-2006
    Posts
    127

    thank you

    this worked thank you ver much for your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1