QTP在EXCEL里面添加超联接的方法

    xiaoxiao2021-12-14  17

    脚本作用:在d盘根目录下创建test.xsl 文件,A1,A2 分别写入:Tom,Sohu 并分别为其创建超链接:http://www.tom.com ,http://www.sohu.com 。

     

    Sub ReportInformation(filename)     Set ExcelObj = CreateObject("Excel.Application")    ExcelObj.Workbooks.Add  Set NewSheet = ExcelObj.Sheets.Item(1)  NewSheet.Name = "Page Information"  NewSheet.Cells(1,1).Value = "Tom"     NewSheet.Cells(2,1).Value = "Sohu"   NewSheet.Hyperlinks.Add NewSheet.Cells(1,1), "http://www.tom.com/"   NewSheet.Hyperlinks.Add NewSheet.Cells(2,1), "http://www.sohu.com/"       ExcelObj.ActiveWorkbook.SaveAs filename           ExcelObj.Quit       Set ExcelObj = Nothing       End Sub call ReportInformation("d:\test.xls") 

    转载请注明原文地址: https://ju.6miu.com/read-969339.html

    最新回复(0)