Announcement

Collapse
No announcement yet.

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

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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.


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


    Jon G
    GizmoCoder.Com

    Comment


    • #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)

      Comment


      • #4
        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

        Comment


        • #5


          Thanks

          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
          .

          Comment

          Working...
          X