学了vba学java_使用excel vba实现自动化

这篇博客探讨了如何使用VBA在Excel中激活特定工作表,并通过VBA与Internet Explorer交互,查找含有特定URL的窗口。进一步地,它展示了如何定位网页中的表格元素,特别是具有' MenuTable '类的元素,以及如何遍历这些元素,根据innerText找到并点击匹配项,例如' Default WFM Group '。
摘要由CSDN通过智能技术生成

试一试 . 它应首先选择表,然后选择属于该表的所有元素并根据InnerText进行匹配 .

Sub WFM_test()

Dim AllTableItems As Object

Dim element As Object

Sheets("Preenchimento_Remedy").Activate

Wd = Range("D02").Value 'URL address

Set objShell = CreateObject("Shell.Application")

Set objAllWindows = objShell.Windows

For Each ow In objAllWindows

'MsgBox ow

If (InStr(1, ow, "Internet Explorer", vbTextCompare)) Then

'MsgBox ow.Hwnd & " " & ow & " " & ow.locationURL

If (InStr(1, ow.LocationURL, Wd, vbTextCompare)) Then

Set objRemedy = ow

End If

End If

Next

If Not objRemedy Is Nothing Then

' you need this (0) as you specify which class you want to select

' The classname is not a unique property

Set Table = objRemedy.Document.getElementsByClassName("MenuTable")(0)

'Select all Elements in the table

Set AllTableItems = Table.getElementsbyTagName("*")

'Iterate over the elements in the table and find the match

For Each element In AllTableItems

If element.InnerText = "Default WFM Group" Then element.Click

Next i

End If

End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值