Ad Home

Theme images by kelvinjay. Powered by Blogger.

Travel

Header Ads

Java

Selenium

UFT

Framework

General QA Concept

BDD

» » How to run an excel macro using QTP?

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 QTP 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 QTP 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 QTP and start QTP 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",


Hope this will help you.

«
Next
Newer Post
»
Previous
Older Post

1 comments:

  1. Thanks, seems good, though need to try.
    Thanks a lot.

    ReplyDelete