使用Excel VBA在Internet Explorer文本框中输入值

使用Excel VBA在Internet Explorer文本框中输入值,vba,internet-explorer,excel,Vba,Internet Explorer,Excel,VBA/StackOverflow/等的新功能。我的代码当前打开Internet Explorer,导航到URL,检查是否已登录,必要时登录,然后导航到新页面 现在我想在InternetExplorer文本框中输入一个字符串值 以下是相关元素的HTML源代码: <input type="text" class="search_customDate" name="dateFrom" id="dateFrom" value="mm/dd/yy" size="13" onchange="RTS

VBA/StackOverflow/等的新功能。我的代码当前打开Internet Explorer,导航到URL,检查是否已登录,必要时登录,然后导航到新页面

现在我想在InternetExplorer文本框中输入一个字符串值

以下是相关元素的HTML源代码:

<input type="text" class="search_customDate" name="dateFrom" id="dateFrom"
value="mm/dd/yy" size="13" 
onchange="RTSDHTMLUTIL.getRTSDHTML('dateFrom').onChange(event);" 
OnFocus OnBlur />

<input type="text" class="search_customDate" name="dateTo" id="dateTo" 
value="mm/dd/yy" size="13" 
onchange="RTSDHTMLUTIL.getRTSDHTML('dateTo').onChange(event);" 
OnFocus OnBlur />    <INPUT id="dateTo" class="search_customDate" 

<input type="text" class="search_companyLookupField" name="tokens" id="tokens" 
value title OnChange OnMouseOver OnMouseOut OnKeyDown="doLookup(event);" 
OnKeyUp OnFocus OnBlur OnDisable />
到目前为止,文本框中没有显示任何内容,我似乎不知道为什么。愿意听取任何人的意见/建议


谢谢

我从这里开始:

删除HTML元素变量名称后的0-getElementByID方法返回唯一的元素,而不是集合 确保您试图检索的HTML输入元素实际上没有返回任何内容
'Input From and To dates
Dim DateFrom As Object ' MSHTML.HTMLInputElement
Set DateFrom = AppIE.Document.getElementByID("dateFrom")
If Not DateFrom Is Nothing Then
    DateFrom(0).Value = "05/05/05"
End If

Dim DateTo As Object ' MSHTML.HTMLInputElement
Set DateTo = AppIE.Document.getElementByID("dateTo")
If Not DateTo Is Nothing Then
    DateTo(0).Value = "06/06/06"
End If

Dim Ticker As Object ' MSHTML.HTMLInputElement
Set Ticker = AppIE.Document.getElementByID("tokens")
If Not Ticker Is Nothing Then
   Ticker(0).Value = "XYZ"
End If