+ Reply to Thread
Results 1 to 5 of 5

Input and Retrieve Data from DOS

  1. #1
    Registered User
    Join Date
    07-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    47

    Input and Retrieve Data from DOS

    I know this may sound a little convoluted to be run as an Excel macro, but nevertheless I would appreciate any help...if it can even be done, which I'm not sure:

    Basically, I want the Excel user to input a single term somwehere which would then be used as part of a command line operation in DOS. Then, the result of the DOS operation (which would be one row) would then be copied out of DOS and pasted somewhere into the Excel spreadsheet.

    For example:

    1) User enters "apple" somewhere in a spreadsheet (could be dialog box or just a cell)
    2) MS-DOS opens and runs command "cres xxx %apple%"
    3) The result in DOS is "FRUIT,RED,ROUND,1,1,,,U"
    4) "FRUIT,RED,ROUND,1,1,,,U" gets entered into a cell somewhere in Excel

    Thanks!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,050

    Re: Input and Retrieve Data from DOS

    In broad terms, yes this is possible.

    At the end of the process, you will end up with three text files: a "flag" file, a batch file and a "query output" text file. If you want to be tidy, you can kill the flag file and the batch file after you have recovered the data. In fact you can kill the query output file.

    The steps would be:

    1. kill a "flag" file at the beginning of the process. This is a simple text file and does not need any content.
    2. in Excel, build a batch file to run your command
    run the "query" and route the output to a text file ... one line output
    as the last task in the batch file, re-create the "flag" file
    3. use shell to open a CMD box and run the batch file you just created
    4. in the Excel code, loop until the flag file exists; you need to put a realistic time limit on this loop
    5. when it does, the batch file is complete
    open and read the query text file output
    store the content in the cell
    6. kill all the three text files.

    Done


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Input and Retrieve Data from DOS

    Alright. Thanks but...I should tell you I don't know how to do any of that. =(

  4. #4
    Registered User
    Join Date
    07-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Input and Retrieve Data from DOS

    Actually, nevermind. Requirements have changed and I don't need it for now. Thanks, tho!

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,050

    Re: Input and Retrieve Data from DOS

    OK.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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