+ Reply to Thread
Results 1 to 2 of 2

VBA code to open and execute files from different directories in Commend window

  1. #1
    Registered User
    Join Date
    09-26-2012
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    4

    VBA code to open and execute files from different directories in Commend window

    I have the following problem that I hope someone knows the solution of.
    First, I open a command window from VBA by
    strPrgm0= "C:\WINDOWS\system32\cmd.exe"
    Call Shell(strPrgm0, 1)

    From the command window, I tested that the following command (I typed it in), which opens an Rscript and runs an R file from different directories, works:
    C:\somepath\>"c:\DirectoryA\Rscript.exe" "c:\DirectoryB\TestRun.r"

    My question is, how do I do the same (making the command line call) to execute the R run from VBA?

    Thanks a lot.

  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

    Re: VBA code to open and execute files from different directories in Commend window

    Hello AlexXYZ,

    Copy and paste this code into a VBA Module. Call the macro "RunFile" to start "TestRun.r".
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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