VBA的getElementById不适用于按钮 [英] VBA getElementById doesn't work for button

查看:342
本文介绍了VBA的getElementById不适用于按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问网站,在文本框中键入一个值,然后单击搜索按钮以搜索我的值. 我的问题是,我无法获取按钮元素来触发click事件.

I am trying to go on a website, type a value in a textbox and then click the searchbutton to search for my value. My Problem is, that i can't get the button element, to fire the click event.

VBA:

Dim i As Long
Dim objElement As Object
Dim objCollection As Object
 Dim result(2) As String
Dim timeout As Integer

Dim test As Object 'testweise

If IE Is Nothing = False Then
    IE.Quit
End If
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True


Start:

' Send the form data To URL As POST binary request
IE.navigate "https://www.bundesanzeiger.de/ebanzwww/wexsservlet"

' Wait while IE loading...
Do While IE.Busy
    DoEvents
    Application.Wait DateAdd("s", 1, Now)
Loop
IE.Document.getElementbyid("genericsearch_param.fulltext").Value = "Mielke"
IE.Document.getElementbyid("(page.navid=to_quicksearchlist)").Click

HTML

<div class="bbg"><input name="(page.navid=to_quicksearchlist)" type="submit" alt="Suchen" value="Suchen"></div>

应该使用secont getElement调用来获取按钮,但是该对象为null. 有人知道我在哪里做错了吗?

the secont getElement call is supposed to get the button, the object is null though. Does anyone know where i did a mistake?

推荐答案

替换:

IE.Document.getElementbyid("(page.navid=to_quicksearchlist)").Click

具有:

Set x = IE.Document.GetElementsByName("(page.navid=to_quicksearchlist)")
x(0).Click

您需要按名称而不是 Id

这篇关于VBA的getElementById不适用于按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆