无法使用VBA在Web表单的组合框中设置值

问题描述

我有一个要使用VBA自动填写的Web表单。下面的代码对表单中的所有文本元素均能正常工作,但无法在表单的组合框中设置值(返回错误438)。通过检查HTML代码,我可以看到该对象没有任何值。

HTML中的对象详细信息

<span title="Choose Currency" class="select2-selection__rendered" id="select2-currency-container">Choose Currency</span>
Option Explicit

Sub WebFormDataEntry()

    Dim IE As Object
    Dim doc As HTMLDocument
    
    Set IE = CreateObject("InternetExplorer.Application")
  
    IE.Visible = True
    IE.navigate "https://webaddress"
    
    
    do while IE.Busy
        Application.Wait DateAdd("s",1,Now)
    Loop

    
    'Set intellisense.
    Set doc = IE.document
    
    
    With doc
        
        .getElementById("amount").Value = 9.99
        
        .getElementById("iban").Value = "GB7911111111111"
        
        .getElementById("beneficiaryName").Value = "John Smith"
        
        .getElementById("beneficiaryCity").Value = "London"
        
        .getElementById("beneficiaryAddress").Value = "16 Baker's street"
        
        .getElementById("paymentDetails").Value = "inv 4444"
        
        .getElementById("swift").Value = "BRCLGBLO"
        
        .getElementById("beneficiaryBank").Value = "Barcly's bank"
        
        .getElementById("beneficiaryBankAddress").Value = "101 Big Ben street"
        
        
        'UP TO THIS POINT ALL WORKS FINE!
        
        
        'This one returns Error 438. In HTML code this object does not have any values.
        .getElementById("select2-currency-container").Value = "EUR"
        
        
    End With
    
End Sub

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)