How to Run Excel Macro using UFT?

1
202
Spread the love
  • 15
  • 23
  • 12
  • 22
  •  
  •  
  •  
  •  
  •  
  •  
    72
    Shares

 

Excel Macro using UFT
run excel macro from uft

Excel Macro using UFT

How to Run Excel Macro using UFT?:

This post talks about a generic problem in our daily testing life.
Say I have a scenario where I need to generate some output through UFT and based on that output I need to do some operation in Excel.
There are two ways to do that Either generate the output first to and excel and try to excel coding through UFT or simple generate the output and call a inbuilt macro that will do rest. I found the later one is the best solution…

1.I have an excell sheet that needs to be run and execute its in built macro
2. After the executed result of the macro,I need to add that output excell to UFT and start UFT execution

We were having problems as the excell sheets data are dynamic and there was a manual intervention every time when we tried to do Step-1 and Step-2 one after another.
Later the solution is found..
The solution is:
Strat the QTP execution–>QTP will trigger the Macro—>Then it will import the executed sheet —->do its normal execution.

The code is:


Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open("C:filename.xls")
objExcel.Visible = True
'Replace "macroname", "params1", "param2" with' the appropriate values
objExcel.Run "macroname", "params1", "param2"
'If there is no parameter for your macro .You can leave this place blank
like
objExcel.Run "macroname"
 

 

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 15
  • 23
  • 12
  • 22
  •  
  •  
  •  
  •  
  •  
  •  
    72
    Shares

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here