Excel控制IE

VBA操作IE浏览器示例

---恢复内容开始---

1、初始化and连接http网页
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "http://10.251.68.38:8088/....."
Do Until ie.Readystate = 4
    DoEvents
Loop
2、索引对象
  1.by id/name(getElementById搜索时包揽id、name)
ie.Document.getElementById("name").Value = "aaa"
   2.by tagName
For i = 0 To ie.Document.All.Length - 1
    If UCase(ie.Document.All(i).tagName) = "INPUT" Then
        If UCase(ie.Document.All(i).Type) = "IMAGE" Then
            ie.Document.All(i).Click
            Exit For
        End If
    End If
Next
  3.访问frame内元素
For k = 0 To ie.Document.frames.Length - 1
    For i = 0 To ie.Document.frames(k).Document.All.Length - 1
        If UCase(ie.Document.frames(k).Document.All(i).tagName) = "A" Then
            ss = ie.Document.frames(k).Document.All(i).href
            If InStr(1, ss, "menuID=201", vbTextCompare) > 0 Then
'            If ie.Document.frames(k).Document.All(i).href = "../inventory/searchInv.jsp?menuID=201" Then
                ie.Document.frames(k).Document.All(i).Click
                Exit For
            End If
        End If
    Next
Next

3、读取、修改元素属性

 元素各个属性能直接访问,如

ie.Document.All(“name”).Value

ie.Document.All(i).scr

ie.Document.All(i).href

 

转载于:https://www.cnblogs.com/lulu147/p/5653736.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值