Forum Discussion

Oussama's avatar
Oussama
Occasional Contributor
10 years ago
Solved

Execute VBA Excel Macro from TestComplete Script

Hello,

 

I have the following need :

 

- I can open an Excel workbook from my TestComplete script. This excel Workbook has two VBA macros : toto() and titi()

 

- Now, I want to execute only the macro toto() that exists in this excel workbook (without titi()). I don't want to execute this macro toto() on the opening of the excel Workbook.

 

So, I need to launch this macro toto() from my TestComplete script, after the opening of the excel workbook. Is it possible ? How ?

 

Thanks for your answer.

 

BR,

Oussama Naffeti.

 

 

  • Hi Oussama,

    We have a sample article demonstrating how to execute a macro:

    function Test()
    {
      // Gets Excel objects
      var excel = Sys.OleObject("Excel.Application");
     
      // Runs a macro
      excel.Run("toto")
    }

     

3 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Oussama,

    We have a sample article demonstrating how to execute a macro:

    function Test()
    {
      // Gets Excel objects
      var excel = Sys.OleObject("Excel.Application");
     
      // Runs a macro
      excel.Run("toto")
    }

     

    • anumolu9999's avatar
      anumolu9999
      Contributor
      If we want to pass arguments to the macro. How can we do it?