Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 5 of 5

Thread: Launch Excel from DOS Batch file and tell it to run Macro???

  1. #1
    Join Date
    30th June 2004
    Posts
    3

    Launch Excel from DOS Batch file and tell it to run Macro???

    I need to edit a .csv file which is generated from another program.
    What I do now is have a DOS batch file which runs the program to generate the file then opens the file in excel.

    I then manually run a macro to format/sort the data.

    How can I automate the step to run the macro?
    Wasn't there at one time a commandline switch to specify a macro?

    Any help would be appreciated.

    - MM

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    11th June 2004
    Location
    Canada
    Posts
    153

    MAcro

    You can use the Auto_Open sub to run any macro you wish. This Sub will execute as soon as the worksheet is opened.


    VB:
    Sub Auto_Open() 
         'Code to execute
    End Sub 
    
    

  3. #3
    Join Date
    30th June 2004
    Posts
    3
    I have received the same reply on many forums but....

    The .csv file generated by a separate program is NOT an excel file and can NOT have macros/events.

    I am not converting to excel, I am editing a .csv file then resaving as a .csv

    My question is specifically aimed at externally (DOS Batch file) telling Excel to open a .csv file and then run a macro defined in the personal.xls (Personal workbook)

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    30th June 2004
    Posts
    9
    Try creating an Excel file to open after the CSV file. Your batch script would work as follows:

    ...
    Open MyFile.csv with Excel
    Open MyUtility.xls with Excel
    ...

    MyUtility.xls could contain the Auto_Open macro to perform the necessary work on MyFile.csv.

    bgano

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    30th June 2004
    Posts
    3

    Thanks

    Quote Originally Posted by bgano
    Try creating an Excel file to open after the CSV file. Your batch script would work as follows:

    ...
    Open MyFile.csv with Excel
    Open MyUtility.xls with Excel
    ...

    MyUtility.xls could contain the Auto_Open macro to perform the necessary work on MyFile.csv.

    bgano

    Thanks, I give that a try.
    I was hoping there was a way to call a macro from the commandline via a startup switch
    .

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Run Dos Batch File
    By dddorian in forum EXCEL HELP
    Replies: 1
    Last Post: August 30th, 2007, 23:00
  2. Macro To Run Command Prompt Batch File
    By Swarris in forum EXCEL HELP
    Replies: 4
    Last Post: March 2nd, 2007, 05:20
  3. Trying to run a Batch file using VBA.
    By Michael Garrett in forum EXCEL HELP
    Replies: 28
    Last Post: September 30th, 2004, 03:12
  4. Dynamic table refresh macro, batch file, etc.
    By Graig in forum EXCEL HELP
    Replies: 2
    Last Post: April 10th, 2003, 00:18
  5. excel macro from a batch file?
    By nospam in forum EXCEL HELP
    Replies: 8
    Last Post: February 22nd, 2003, 03:09

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
  •  
porno