Micro Focus QTP (UFT) Forums
Write Heading in excel - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Write Heading in excel (/Thread-Write-Heading-in-excel)

Pages: 1 2 3


RE: Write Heading in excel - Anu - 07-27-2010

Hi,

I was able to get the values in the array but not write in excel.
Whenever i run the script it writes the first header in the excel many times but did not the next header.
The code is:

Code:
Dim sHeaderArray(100)
For i = 0 to 10 'specify your limit for value of n
sHeaderArray(i)= Browser("IE").Page("Google Search").Link("LinkName").GetROProperty("innertext")
'Next
'msgbox(sHeaderArray(0))
'For Wirting in Excel Sheet’
Dim xlApp, xlBook, xlSheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.WorkBooks.Open("F:\Test.xls")
Set xlSheet = xlBook.WorkSheets("Sheet1")
''*** Writing Header***'
      i = 0
    For Each sHeader in sHeaderArray
        i= i+ 1
        xlSheet.Cells(1, i).Value = sHeaderArray
    Next
    Next


Please help me

Waiting for response.

Regards,
Anu


RE: Write Heading in excel - sasmitakumari - 07-27-2010

Corrected....Try now....
Code:
Dim sHeaderArray(10)
For i = 0 to 10 'specify your limit for value of n
sHeaderArray(i)= Browser("IE").Page("Google Search").Link("LinkName").GetROProperty("innertext")
Next

'For Wirting in Excel Sheet’
Dim xlApp, xlBook, xlSheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.WorkBooks.Open("F:\Test.xls")
Set xlSheet = xlBook.WorkSheets("Sheet1")
''*** Writing Header***'
i = 0
For Each sHeader in sHeaderArray
  i= i+ 1
  xlSheet.Cells(1, i).Value = sHeader
Next



RE: Write Heading in excel - Anu - 07-28-2010

Hi,

Iahve done the modifications as per your mail...............
But didn't get the desired result..........
In my previous mail, i had mentioned the problem which is still present after running the modified the code....................
Please find the attached screen shot.
Hope this explain my problem...........

Regards,
Anu


RE: Write Heading in excel - Anu - 07-30-2010

Hi,

Please look into the issue so that i can proceed further..............
Regards,
Anu


RE: Write Heading in excel - sreekanth chilam - 07-30-2010

Hi Anu,

Try with the below code.

Note: Its written in Descriptive Prog., no need of adding objects in OR.
Directly copy below code > paste > Run > Check O/P in excel
Make sure excel file exist in the path "F\Test.xls"

Code:
Systemutil.Run "www.google.com"
Searched_Item="Page"
Browser("title:=Google").Page("title:=Google").WebEdit("name:=q").Set Searched_Item
Browser("title:=Google").Page("title:=Google").WebButton("name:=Google Search").Click
Dim xlApp
Set xlApp=CreateObject("Excel.Application")
xlApp.WorkBooks.Open("C:\Documents and Settings\Sreee\Desktop\Test.xls")
xlApp.Sheets("Sheet1").Select
Set obj=description.Create
obj("micclass").Value="Link"
Set x=Browser("title:="&Searched_Item&" - Google Search").Page("title:="&Searched_Item&" - Google Search").ChildObjects(obj)
   temp=0
   For i=0 to x.count-1
        If (instr(1,x(i).GetROproperty("Innertext"),Searched_Item)>0) Then
              xlApp.Cells(1,temp+1).Value=(x(i).GetROproperty("Innertext"))
              xlApp.Cells(1,temp+1).font.Bold=True
              temp=temp+1
        End if
   Next
   xlApp.ActiveWorkBook.Save
   xlApp.Quit
   Set xlApp=Nothing



RE: Write Heading in excel - MVChowdary - 07-30-2010

Hi Sreekanth,

Perfect code, it is working fine.


RE: Write Heading in excel - Anu - 08-03-2010

Hi,

thnks................
The code is working fine. As u have used Descriptive programming it is little bit difficult for me to understand..................
I want to get good command over Descriptive programming so please suggest me.....................

Moreover,this code writtoing the result as a row wise i want in column wise........

Regards,
Anu


RE: Write Heading in excel - Anu - 08-05-2010

Hi,

for google it is working fine but if i change the url then it creates problem ..... the code the mentioned below:

Code:
Systemutil.Run "http://tdil-dc.in/clia-beta-working/locale.jsp?te"
Searched_Item="ఫతేపూర్‌ "
Browser("title:=tdil-dc.in/clia-beta-working/redirect").Page("title:=tdil-dc.in/clia-beta-working/redirect").WebEdit("name:=q").Set Searched_Item
Browser("title:=tdil-dc.in/clia-beta-working/redirect").Page("title:=tdil-dc.in/clia-beta-working/redirect").WebButton("name:=tdil-dc.in/clia-beta-working/redirect Search").Click
Dim xlApp
Set xlApp=CreateObject("Excel.Application")
xlApp.WorkBooks.Open("F:\Test.xls")
xlApp.Sheets("Sheet1").Select
Set obj=description.Create
obj("micclass").Value="Link"
Set x=Browser("title:="&Searched_Item&" - tdil-dc.in/clia-beta-working/redirect Search").Page("title:="&Searched_Item&" - tdil-dc.in/clia-beta-working/redirect Search").ChildObjects(obj)
   temp=0
   For i=0 to x.count-1
        If (instr(1,x(i).GetROproperty("Innertext"),Searched_Item)>0) Then
              xlApp.Cells(1,temp+1).Value=(x(i).GetROproperty("Innertext"))
              xlApp.Cells(1,temp+1).font.Bold=True
              temp=temp+1
        End if
   Next
   xlApp.ActiveWorkBook.Save
   xlApp.Quit
   Set xlApp=Nothing

Please look it into on urgent basis................
Thanks for your co -operation.

Regards,
Anu