Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel Can';不要让VBA点击IE上的链接_Excel_Vba - Fatal编程技术网

Excel Can';不要让VBA点击IE上的链接

Excel Can';不要让VBA点击IE上的链接,excel,vba,Excel,Vba,我在这里和其他网站上找到了数百种选择,但都没有成功。希望你们能帮助我 我试图通过VBA在IE中单击一个链接,但由于某些原因,它不起作用。我的完整代码在这里 Sub ExtrairPIB() Dim IE As InternetExplorer Dim html As HTMLDocument Set IE = New InternetExplorer IE.Visible = True IE.navigate "http://www.cidades.ibge.gov.br/xtras/uf.

我在这里和其他网站上找到了数百种选择,但都没有成功。希望你们能帮助我

我试图通过VBA在IE中单击一个链接,但由于某些原因,它不起作用。我的完整代码在这里

Sub ExtrairPIB()

Dim IE As InternetExplorer
Dim html As HTMLDocument

Set IE = New InternetExplorer
IE.Visible = True
IE.navigate "http://www.cidades.ibge.gov.br/xtras/uf.php?lang=&coduf=12&search=acre"
Do While IE.ReadyState <> 4
DoEvents
Loop

Set html = IE.document

html.getElementById("m1200013").Click


End Sub
Sub-ExtrairPIB()
Dim IE作为InternetExplorer
将html设置为HTMLDocument
Set IE=新的InternetExplorer
可见=真实
即“导航”http://www.cidades.ibge.gov.br/xtras/uf.php?lang=&coduf=12&search=acre"
请稍等,即ReadyState 4
多芬特
环
设置html=IE.document
html.getElementById(“m1200013”)。单击
端接头
我在这方面没有经验,我不知道这是否正确。以下是控制台上显示的内容

<div id="filtro_mun_letra" style="height: 23px; margin-top: -23px;">
<ul id="lista_municipios">
<li id="m1200013">
<a href="perfil.php?lang=&codmun=120001&search=acre|acrelandia">Acrelândia</a>
</li>

当代码使用click运行命令行时,它不会发生任何事情

请帮帮我,伙计们


提前感谢

您实际上并没有单击该链接,而是单击包含该链接的列表项

将最后几行更改为以下内容:

Set m = html.getElementById("m1200013")
Set a = m.getElementsByTagName("a")(0)
a.Click

我已经过测试并正在努力。

如果这个答案对您有帮助,请将其标记为已接受的答案,或者单击此帖子左侧的复选标记来更新它。这就是我们在StackOverflow中说谢谢的方式。