• Start Excel from command prompt (2002)

    Author
    Topic
    #399127

    Can you not put your code into the Workbook_Open event of an Excel file? Something like:

    Private Sub Workbook_Open()
        [your routine name here]
    End Sub

    HTH

    Viewing 1 reply thread
    Author
    Replies
    • #768374

      Edited by HansV to make URL clickable – see Help 19

      I want to start excel from the command prompt, opening an .xls file and starting a macro.

      Start Excel opening an .xls file is no problem: Excel.exe C:AO-LL.xls, that works.
      I found in the knowledge base an article about the available switches: http://support.microsoft.com/?kbid=211481%5B/url%5D
      The article doesn’t say anything about starting macro’s.
      Does anybody know what to add to the commandline to start a macro?

      • #768382

        Unlike Word, Excel has no command line option to start a macro. The workaround suggested by unkamunka is the one generally recommended.

        • #768417

          Thanks for the quick reply.
          The work-around is not possible in this case.
          I do not want to run the macro when the excel workbook is opened.
          I want to save one of the sheets as a csv file in a batch proces just before processing the csv file.
          Knowing about the possibility to start Word from the command prompt running a macro I assumed the same being possible with Excel.

          • #768422

            Would it be possible to have the Excel code open the target file, process it into the CSV file and then either close the workbook containing the code or close that instance of Excel? HTH

            • #768435

              No, I do not want to have any user actions, it is running in an SQL Server 2000 DTS batch proces.
              I am trying to put it into a VB script now.
              The script has to open the Excelsheet, to save one of the sheets as a csv file and close excel again.
              It doesn’t work yet……

            • #768439

              confusedScript runs Excel.exe C:RunMyRoutine.xls. RunMyRoutine.xls opens target file, saves sheet in CSV format and exits with Application.Quit.

            • #768440

              confusedScript runs Excel.exe C:RunMyRoutine.xls. RunMyRoutine.xls opens target file, saves sheet in CSV format and exits with Application.Quit.

            • #768738

              There are two approaches that I can think of:

              1- Put your code in the Open event routine of the workbook in question. Dream up your own command line switch. Run Excel with the filename and your switch. In the Open event routine, have your code check the command line for your switch, and if it is not there do nothing. If it is there, create the .CSV file and exit Excel using Application.Quit.

              2- Put your code into the Open even routine of another workbook. Run Excel specifing that workbook as the one to open. In the Open event routine, open the real workbook, create the .CSV file, and then exit Excel using Aplication.Quit.

            • #768739

              There are two approaches that I can think of:

              1- Put your code in the Open event routine of the workbook in question. Dream up your own command line switch. Run Excel with the filename and your switch. In the Open event routine, have your code check the command line for your switch, and if it is not there do nothing. If it is there, create the .CSV file and exit Excel using Application.Quit.

              2- Put your code into the Open even routine of another workbook. Run Excel specifing that workbook as the one to open. In the Open event routine, open the real workbook, create the .CSV file, and then exit Excel using Aplication.Quit.

            • #769210

              See if this page gives you some ideas.

              Edited: somehow couldn’t get the url to work.

              Search Google groups, using these keywords:

              excel command line read vba

              Click the first entry.

            • #769211

              See if this page gives you some ideas.

              Edited: somehow couldn’t get the url to work.

              Search Google groups, using these keywords:

              excel command line read vba

              Click the first entry.

            • #768436

              No, I do not want to have any user actions, it is running in an SQL Server 2000 DTS batch proces.
              I am trying to put it into a VB script now.
              The script has to open the Excelsheet, to save one of the sheets as a csv file and close excel again.
              It doesn’t work yet……

          • #768423

            Would it be possible to have the Excel code open the target file, process it into the CSV file and then either close the workbook containing the code or close that instance of Excel? HTH

        • #768418

          Thanks for the quick reply.
          The work-around is not possible in this case.
          I do not want to run the macro when the excel workbook is opened.
          I want to save one of the sheets as a csv file in a batch proces just before processing the csv file.
          Knowing about the possibility to start Word from the command prompt running a macro I assumed the same being possible with Excel.

      • #768383

        Unlike Word, Excel has no command line option to start a macro. The workaround suggested by unkamunka is the one generally recommended.

    • #768375

      Edited by HansV to make URL clickable – see Help 19

      I want to start excel from the command prompt, opening an .xls file and starting a macro.

      Start Excel opening an .xls file is no problem: Excel.exe C:AO-LL.xls, that works.
      I found in the knowledge base an article about the available switches: http://support.microsoft.com/?kbid=211481%5B/url%5D
      The article doesn’t say anything about starting macro’s.
      Does anybody know what to add to the commandline to start a macro?

    Viewing 1 reply thread
    Reply To: Reply #768435 in Start Excel from command prompt (2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel