[英]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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.