+ Reply to Thread
Results 1 to 3 of 3

Executing Command Prompt commands through VBA

  1. #1
    Registered User
    Join Date
    11-22-2012
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    5

    Executing Command Prompt commands through VBA

    Hello everyone,

    I would like VBA to run another program's script file (Gretl) through the Command Prompt.

    In order to manually run Gretl's script through the Command Line I follow these 2 steps:

    (1): cd C:\Program Files\gretl (change directory to the file that holds gretlcli.exe)
    (2): > gretlcli -b "C:\Users\ndw\Desktop\PLS.inp" (this command runs the Gretl scriptfile I created, PLS.inp)

    However, I am at a loss on how to let VBA run this command for me. I looked for some information on how to do this in related topics, but I did not succeed in making it work on my own.
    I tried to use the 'Shell' command (i.e. Shell ("CMD.exe /k CD C:\Program Files\gretl")). While this manages to replicate the first step of my manual proces, namely setting the directory to the Gretl folder, I cannot seem to be able to tell VBA to execute the second part of the command (i.e. running the actual Gretl script).

    Thanks in advance.

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Executing Command Prompt commands through VBA

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-22-2012
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Executing Command Prompt commands through VBA

    Hi Kenneth,

    That did the job. Thanks a lot! I had tried something similar, but apparently did not get the number of quotation marks right.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to run a set of commands in command prompt using vba
    By A N Rahman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2015, 09:05 AM
  2. [SOLVED] ActiveSheet_Change is not automatically executing commands
    By tnuis in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-28-2013, 02:06 PM
  3. VBA to command prompt - sending multiple commands to same line?
    By JP Romano in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-07-2012, 10:42 AM
  4. Excel 2007 : Difficulties executing excel commands
    By Thembinkosi in forum Excel General
    Replies: 2
    Last Post: 01-18-2011, 03:49 AM
  5. executing two different commands with same button
    By robbi100 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2008, 07:06 AM
  6. Executing Excel menu commands from VB
    By Ed White in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-15-2006, 02:25 AM
  7. combinations of checkboxes and executing commands
    By dreamz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-28-2005, 10:34 AM

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