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 VBA自动搜索特定网站_Excel_Vba_Internet Explorer_Macros - Fatal编程技术网

Excel VBA自动搜索特定网站

Excel VBA自动搜索特定网站,excel,vba,internet-explorer,macros,Excel,Vba,Internet Explorer,Macros,我试图制作一个Excel宏,打开IE

我试图制作一个Excel宏,打开IE<然后进入www.selectleaders.com,然后在位置字段中输入位置(理想情况下是从Excel中的单元格中提取,而不是在宏中硬编码),然后激活搜索字段

到目前为止,我有如下内容,但我不知道插入什么???让它工作

有什么建议或提示吗

Sub SelectLeadersSignIn()
Dim ie As Object
Dim location
Dim button
Set ie = CreateObject("InternetExplorer.Application")
With ie
    .Visible = True
    .Navigate ("https://www.selectleaders.com")
    While ie.ReadyState <> 4
        DoEvents
    Wend
    Set location = .document.getElementById("?????")
    Set button = .document.getElementById("?????")
    button.Click
    While ie.ReadyState <> 4
        DoEvents
    Wend
End With
Set ie = Nothing

End Sub
Sub-SelectLeadersSignIn()
模糊的物体
暗位置
暗按钮
设置ie=CreateObject(“InternetExplorer.Application”)
与ie
.Visible=True
.导航(“https://www.selectleaders.com")
而ie.ReadyState 4
多芬特
温德
设置位置=.document.getElementById(“???”)
Set按钮=.document.getElementById(“???????”)
按钮,点击
而ie.ReadyState 4
多芬特
温德
以
设置ie=无
端接头

试着填写你的问号

Set location = .document.getElementById("location")
Set button = .document.getElementById("btnContainer").Children(0)
位置
简单明了,并遵循我的评论。submit按钮没有id,因此必须找到它的父id,然后选择它作为父id的子id


不过,现在您已经识别了这些元素,不确定要对它们做什么。

我通常右键单击网站并选择“检查”。您可以查看源代码并找到组成页面的标记中使用的ID。谢谢。有什么特别的我要找的吗?代码的相关部分(我想)是:
id=location
。因此,使用`Set location=.document.getElementById(“location”)这是我尝试过的方法之一,我得到了一个“类型不匹配”错误:(耶!成功了!非常感谢!!!!:)(有什么我必须特别做的事情来标记这个问题已经解决了吗?)太好了。看起来你是用绿色的复选标记做的。很高兴我能有所帮助。