04-02-2013, 01:33 PM
Code:
I have come up with the following code for the above problem,it runs fine for the first iteration, but it throws general run error at the second iteration, where the value of i=1. what is causing this error ??
'invoke the global site selector page
Systemutil.Run "iexplore.exe",Datatable("in_URL", dtLocalSheet),"open"
wait 10
'__________________________________________________________________________________
Set obj=Description.Create()
obj("micclass").value="Link"
Set links=Browser("EMC : Global Site Selector").Page("EMC : Global Site Selector").ChildObjects (obj)
countLinks=links.Count-3
msgbox "Num of countries" & links.Count-3
'____________________________________________________________________________________
'Create a new Microsoft Excel object
Set myxl = createobject("excel.application")
myxl.Workbooks.Open "C:\Users\accbajpa\Desktop\qtp.xls"
myxl.Application.Visible = true
'this is the name of Sheet in Excel file "qtp.xls" where data needs to be entered
set mysheet = myxl.ActiveWorkbook.Worksheets("Sheet1")
'_____________________________________________________________________________________
For i=0 to countLinks
tag= links(i).GetROProperty("name")
links(i).click
href=Browser("EMC : Global Site Selector").Page("EMC:open page").GetROProperty("url")
'_______________________________________________________________________________________
'Enter values in Sheet1.
mysheet.Range("A2").Offset(i,0).value=tag
mysheet.Range("B2").Offset(i,0).value=href
'__________________________________________________________________________________________
'go back to the page
browser("EMC : Global Site Selector").Back
Browser("EMC : Global Site Selector").Page("EMC : Global Site Selector").Sync
'________________________________________________________________________________________
Next
'________________________________________________________________________________________
'Save the Workbook
myxl.ActiveWorkbook.Save