'定义变量 Dim fso,filePath,i Dim ExcelBook, ExcelSheet, myExcelBook, myExcelSheet
'保存Excel表格所放的路径 filePath="E:\a.xls"
'创建Excel应用程序的对象 Set
fso=CreateObject("Scripting.FileSystemobject") Set ExcelBook=Createobject("Excel.Application") Set ExcelSheet=Createobject("Excel.Sheet")
'把Excel表中的Sheet1给一个变量 Set myExcelBook=ExcelBook.WorkBooks.open(filePath) Set myExcelSheet=myExcelBook.worksheets("Sheet1")
'创建一个描述性编程中的description对象,用来复习一下description的创建方法 Set myDesc = Description.Create() '从Excel文件中循环读取数据 For i=1 to 4
systemutil.Run"iexplore.exe","www.baidu.com"
If Browser("百度搜索_深圳").page("百度搜索_深圳").Exist Then myExcelSheet.Cells(i,2).Font.Color = vbBlue myExcelSheet.Cells(i,2).Value ="Pass" else if Browser(myDesc).page(myDesc).Exist then
myExcelSheet.Cells(i,2).Font.Color = vbBlue
myExcelSheet.Cells(i,2).Value="Pass" else if
Browser("opentitle:=百度搜索_播布客").page("opentitle:=百度搜索_播布客").Exist then
myExcelSheet.Cells(i,2).Font.Color = vbBlue
myExcelSheet.Cells(i,2).Value="Pass"
else if Browser("opentitle:=百度搜索_小强").page("opentitle:=百度搜索_小强").Exist then
myExcelSheet.Cells(i,2).Font.Color = vbBlue
myExcelSheet.Cells(i,2).Value="Pass"
else
myExcelSheet.Cells(i,5).Font.Color = vbRed
myExcelSheet.Cells(i,2).Value="Fail"
end if end if end if End If systemutil.CloseProcessByName("iexplore.exe") Next '保存写入的Excel数据 myExcelBook.Save