【发布时间】:2017-05-01 05:53:58
【问题描述】:
尝试创建一个在 IE 中打开多个选项卡并填充文本区域的 vba excel 脚本。 像这样的:
Sub tab_test()
link1 = "somelink1.com"
link2 = "somelink2.com"
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate link1
While IE.busy Or IE.readyState <> 4: DoEvents: Wend
Set IEdoc = IE.document
For Each tag In IEdoc.getElementsByTagName("textarea")
submit_comment = "Some content No1"
tag.Value = submit_comment
Next tag
IE.Navigate2 link2, 2048
While IE.busy Or IE.readyState <> 4: DoEvents: Wend
Set IEdoc2 = IE.document 'Here is the problem. It does not get the new document, but the first tab
For Each tag In IEdoc2.getElementsByTagName("textarea")
submit_comment = "Some content No2"
tag.Value = submit_comment
Next tag
End Sub
问题是当我尝试将 IEdoc2 设置为新文档时,它会将其设置为第一个。
【问题讨论】: