试一试 . 它应首先选择表,然后选择属于该表的所有元素并根据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