如何点击回车触发搜索

时间:2014-03-04 10:07:07

标签: excel-vba web triggers command vba

我想添加一段代码,在代码添加到搜索表单后自动按Enter键。

网址如下: http://www.nook.com/gb/store/books

到目前为止我的代码(由于我没有在搜索框中看到代码,因此无效。)

Selection.Copy

IE.Document.getElementByid(“_ skeyword”)。Value = ActiveCell.Value

我对编码很陌生,所以任何帮助都会受到高度赞赏!

先谢谢你们!

1 个答案:

答案 0 :(得分:0)

当我们点击输入时,它只是通过导航到URL来获取请求。请尝试以下代码。

Sub SearchBook()

    Dim URL As String
    URL = "http://www.nook.com/gb/store/books"

    Dim bookname As String
    bookname = "visions trips and crowded rooms"


    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")
    IE.navigate URL
    IE.Visible = True


    Application.Wait Now + TimeSerial(0, 0, 5)
    MsgBox "Site will now search for book"

    IE.navigate "http://www.nook.com/gb/search?utf8=%E2%9C%93&%5Bs%5Dkeyword=" & bookname

End Sub