Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write Heading in excel
#21
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#22
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#23
Solved: 10 Years, 8 Months, 2 Weeks ago
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


Attached Files Image(s)
   
Reply
#24
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi,

Please look into the issue so that i can proceed further..............
Regards,
Anu
Reply
#25
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#26
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi Sreekanth,

Perfect code, it is working fine.
Reply
#27
Solved: 10 Years, 8 Months, 2 Weeks ago
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


Attached Files Image(s)
   
Reply
#28
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Write in Excel Continued Anu 3 3,155 08-27-2010, 08:53 AM
Last Post: basanth27
  Write in Excel Anu 48 28,604 08-25-2010, 06:08 PM
Last Post: Saket

Forum Jump:


Users browsing this thread: 2 Guest(s)