无法使用 VBA 将所有下拉值从 ui 拉到 excel
Unable to pull all dropdown values from ui to excel using VBA
下面是将下拉列表的选定值拉入 excel 的代码。但我想提取该下拉列表的所有值。请帮助我并提前致谢。
Public Sub lucky()
Set winShell = CreateObject("Shell.Application")
Set objShellWindows = winShell.Windows
Set objshell = CreateObject("Wscript.shell")
For Each ie1 In winShell.Windows
If Left(ie1.locationURL, 66) = "https://lraca-qa.wellsfargo.com/LegalAnalysis/ChangeAlertAdd.aspx" Then
Set IE = ie1
Exit For
End If
Next
Dim TypeOfChange
Set TypeOfChange = IE.Document.getElementById("ctl00_Main_wfcGeneralInfoEdit_fbxGeneralInfo_ddlTypeOfChange")
Sheet1.Cells(1, 2) = TypeOfChange.Item(TypeOfChange.selectedIndex).innerText
MsgBox "done"
End Sub
Dim x As Long
x = TypeOfChange.Options.Length
'Options is zero-based, so need to count from 0 to x-1
For i = 0 to x-1
Sheet1.Cells(i+1, "A").Value = TypeOfChange.Options(i).Text
'if you need the value for the option...
Sheet1.Cells(i+1, "B").Value = TypeOfChange.Options(i).Value
Next
下面是将下拉列表的选定值拉入 excel 的代码。但我想提取该下拉列表的所有值。请帮助我并提前致谢。
Public Sub lucky()
Set winShell = CreateObject("Shell.Application")
Set objShellWindows = winShell.Windows
Set objshell = CreateObject("Wscript.shell")
For Each ie1 In winShell.Windows
If Left(ie1.locationURL, 66) = "https://lraca-qa.wellsfargo.com/LegalAnalysis/ChangeAlertAdd.aspx" Then
Set IE = ie1
Exit For
End If
Next
Dim TypeOfChange
Set TypeOfChange = IE.Document.getElementById("ctl00_Main_wfcGeneralInfoEdit_fbxGeneralInfo_ddlTypeOfChange")
Sheet1.Cells(1, 2) = TypeOfChange.Item(TypeOfChange.selectedIndex).innerText
MsgBox "done"
End Sub
Dim x As Long
x = TypeOfChange.Options.Length
'Options is zero-based, so need to count from 0 to x-1
For i = 0 to x-1
Sheet1.Cells(i+1, "A").Value = TypeOfChange.Options(i).Text
'if you need the value for the option...
Sheet1.Cells(i+1, "B").Value = TypeOfChange.Options(i).Value
Next