Why my google search macro is returning error 424 - Object required?
I have this simple macro that opens up IE and type a word in search box. It was working before, but now is returning
Error 424 - Object required.
Any ideas on what is happening? Is there any lib reference that I'm missing?
Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate ("https://www.google.com/")
Do While ie.Busy Or ie.readyState <> 4
DoEvents
Loop
Set xobj = ie.document.getElementById("lst-ib")
Call xobj.setAttribute("value", "teste")
End Sub
html excel vba excel-vba web-scraping
add a comment |
I have this simple macro that opens up IE and type a word in search box. It was working before, but now is returning
Error 424 - Object required.
Any ideas on what is happening? Is there any lib reference that I'm missing?
Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate ("https://www.google.com/")
Do While ie.Busy Or ie.readyState <> 4
DoEvents
Loop
Set xobj = ie.document.getElementById("lst-ib")
Call xobj.setAttribute("value", "teste")
End Sub
html excel vba excel-vba web-scraping
What line errors? Is it copied code missing the HTML references used forxobj
do you have a new version of web browser? Has something changed in the environment since?
– Nathan_Sav
Nov 22 '18 at 13:56
On which line is error?
– QHarr
Nov 22 '18 at 13:56
you need to remove the parenthesis hereie.Navigate ("https://www.google.com/")
– Pᴇʜ
Nov 22 '18 at 14:03
Actually this is part of a big search and fill vba and I find this piece with error. The error line is the Set xobj = ie.document.getElementById("lst-ib")
– Rafael Torres
Nov 22 '18 at 14:11
Removed the parenthesis and used the[title=Pesquisar]
solution and it worked. Thank you
– Rafael Torres
Nov 22 '18 at 16:10
add a comment |
I have this simple macro that opens up IE and type a word in search box. It was working before, but now is returning
Error 424 - Object required.
Any ideas on what is happening? Is there any lib reference that I'm missing?
Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate ("https://www.google.com/")
Do While ie.Busy Or ie.readyState <> 4
DoEvents
Loop
Set xobj = ie.document.getElementById("lst-ib")
Call xobj.setAttribute("value", "teste")
End Sub
html excel vba excel-vba web-scraping
I have this simple macro that opens up IE and type a word in search box. It was working before, but now is returning
Error 424 - Object required.
Any ideas on what is happening? Is there any lib reference that I'm missing?
Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate ("https://www.google.com/")
Do While ie.Busy Or ie.readyState <> 4
DoEvents
Loop
Set xobj = ie.document.getElementById("lst-ib")
Call xobj.setAttribute("value", "teste")
End Sub
html excel vba excel-vba web-scraping
html excel vba excel-vba web-scraping
edited Nov 22 '18 at 14:11


QHarr
34.1k82044
34.1k82044
asked Nov 22 '18 at 13:52
Rafael TorresRafael Torres
175
175
What line errors? Is it copied code missing the HTML references used forxobj
do you have a new version of web browser? Has something changed in the environment since?
– Nathan_Sav
Nov 22 '18 at 13:56
On which line is error?
– QHarr
Nov 22 '18 at 13:56
you need to remove the parenthesis hereie.Navigate ("https://www.google.com/")
– Pᴇʜ
Nov 22 '18 at 14:03
Actually this is part of a big search and fill vba and I find this piece with error. The error line is the Set xobj = ie.document.getElementById("lst-ib")
– Rafael Torres
Nov 22 '18 at 14:11
Removed the parenthesis and used the[title=Pesquisar]
solution and it worked. Thank you
– Rafael Torres
Nov 22 '18 at 16:10
add a comment |
What line errors? Is it copied code missing the HTML references used forxobj
do you have a new version of web browser? Has something changed in the environment since?
– Nathan_Sav
Nov 22 '18 at 13:56
On which line is error?
– QHarr
Nov 22 '18 at 13:56
you need to remove the parenthesis hereie.Navigate ("https://www.google.com/")
– Pᴇʜ
Nov 22 '18 at 14:03
Actually this is part of a big search and fill vba and I find this piece with error. The error line is the Set xobj = ie.document.getElementById("lst-ib")
– Rafael Torres
Nov 22 '18 at 14:11
Removed the parenthesis and used the[title=Pesquisar]
solution and it worked. Thank you
– Rafael Torres
Nov 22 '18 at 16:10
What line errors? Is it copied code missing the HTML references used for
xobj
do you have a new version of web browser? Has something changed in the environment since?– Nathan_Sav
Nov 22 '18 at 13:56
What line errors? Is it copied code missing the HTML references used for
xobj
do you have a new version of web browser? Has something changed in the environment since?– Nathan_Sav
Nov 22 '18 at 13:56
On which line is error?
– QHarr
Nov 22 '18 at 13:56
On which line is error?
– QHarr
Nov 22 '18 at 13:56
you need to remove the parenthesis here
ie.Navigate ("https://www.google.com/")
– Pᴇʜ
Nov 22 '18 at 14:03
you need to remove the parenthesis here
ie.Navigate ("https://www.google.com/")
– Pᴇʜ
Nov 22 '18 at 14:03
Actually this is part of a big search and fill vba and I find this piece with error. The error line is the Set xobj = ie.document.getElementById("lst-ib")
– Rafael Torres
Nov 22 '18 at 14:11
Actually this is part of a big search and fill vba and I find this piece with error. The error line is the Set xobj = ie.document.getElementById("lst-ib")
– Rafael Torres
Nov 22 '18 at 14:11
Removed the parenthesis and used the
[title=Pesquisar]
solution and it worked. Thank you– Rafael Torres
Nov 22 '18 at 16:10
Removed the parenthesis and used the
[title=Pesquisar]
solution and it worked. Thank you– Rafael Torres
Nov 22 '18 at 16:10
add a comment |
1 Answer
1
active
oldest
votes
That id doesn't appear against the input box when I open google. You can use an attribute = value selector to target the title
attribute of the search box. Right-click inspect the search box and see what your local language attribute value is for title=. In U.K. the value is Search
. Use whatever your local value is.
Element html:
Other:
Also, .navigate2
is the preferred method.
If the page is slow loading you may need a loop until element present.
Option Explicit
Public Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate2 "https://www.google.com/"
While .Busy Or .readyState < 4: DoEvents: Wend
Set xobj = .document.querySelector("[title=Search]")
xobj.Value = "teste"
Stop
.Quit
End With
End Sub
Tried your code and got the same error on Set xobj = .document.querySelector("[title=Search]")
– Rafael Torres
Nov 22 '18 at 14:12
Did you check what your html gives as the title attribute value? If it doesn't say Search and says something like Buscar then you need to change to [title=Buscar]
– QHarr
Nov 22 '18 at 14:13
If the page is slow loading you may need a loop until element present. If you can confirm what the title value is for the attribute and that it still doesn't work I will add loop code in above.
– QHarr
Nov 22 '18 at 14:16
1
Thank you everyone! @QHarr I updated the code with your solution and it worked like a charm. My local value was[title=Pesquisar]
– Rafael Torres
Nov 22 '18 at 16:08
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432490%2fwhy-my-google-search-macro-is-returning-error-424-object-required%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
That id doesn't appear against the input box when I open google. You can use an attribute = value selector to target the title
attribute of the search box. Right-click inspect the search box and see what your local language attribute value is for title=. In U.K. the value is Search
. Use whatever your local value is.
Element html:
Other:
Also, .navigate2
is the preferred method.
If the page is slow loading you may need a loop until element present.
Option Explicit
Public Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate2 "https://www.google.com/"
While .Busy Or .readyState < 4: DoEvents: Wend
Set xobj = .document.querySelector("[title=Search]")
xobj.Value = "teste"
Stop
.Quit
End With
End Sub
Tried your code and got the same error on Set xobj = .document.querySelector("[title=Search]")
– Rafael Torres
Nov 22 '18 at 14:12
Did you check what your html gives as the title attribute value? If it doesn't say Search and says something like Buscar then you need to change to [title=Buscar]
– QHarr
Nov 22 '18 at 14:13
If the page is slow loading you may need a loop until element present. If you can confirm what the title value is for the attribute and that it still doesn't work I will add loop code in above.
– QHarr
Nov 22 '18 at 14:16
1
Thank you everyone! @QHarr I updated the code with your solution and it worked like a charm. My local value was[title=Pesquisar]
– Rafael Torres
Nov 22 '18 at 16:08
add a comment |
That id doesn't appear against the input box when I open google. You can use an attribute = value selector to target the title
attribute of the search box. Right-click inspect the search box and see what your local language attribute value is for title=. In U.K. the value is Search
. Use whatever your local value is.
Element html:
Other:
Also, .navigate2
is the preferred method.
If the page is slow loading you may need a loop until element present.
Option Explicit
Public Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate2 "https://www.google.com/"
While .Busy Or .readyState < 4: DoEvents: Wend
Set xobj = .document.querySelector("[title=Search]")
xobj.Value = "teste"
Stop
.Quit
End With
End Sub
Tried your code and got the same error on Set xobj = .document.querySelector("[title=Search]")
– Rafael Torres
Nov 22 '18 at 14:12
Did you check what your html gives as the title attribute value? If it doesn't say Search and says something like Buscar then you need to change to [title=Buscar]
– QHarr
Nov 22 '18 at 14:13
If the page is slow loading you may need a loop until element present. If you can confirm what the title value is for the attribute and that it still doesn't work I will add loop code in above.
– QHarr
Nov 22 '18 at 14:16
1
Thank you everyone! @QHarr I updated the code with your solution and it worked like a charm. My local value was[title=Pesquisar]
– Rafael Torres
Nov 22 '18 at 16:08
add a comment |
That id doesn't appear against the input box when I open google. You can use an attribute = value selector to target the title
attribute of the search box. Right-click inspect the search box and see what your local language attribute value is for title=. In U.K. the value is Search
. Use whatever your local value is.
Element html:
Other:
Also, .navigate2
is the preferred method.
If the page is slow loading you may need a loop until element present.
Option Explicit
Public Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate2 "https://www.google.com/"
While .Busy Or .readyState < 4: DoEvents: Wend
Set xobj = .document.querySelector("[title=Search]")
xobj.Value = "teste"
Stop
.Quit
End With
End Sub
That id doesn't appear against the input box when I open google. You can use an attribute = value selector to target the title
attribute of the search box. Right-click inspect the search box and see what your local language attribute value is for title=. In U.K. the value is Search
. Use whatever your local value is.
Element html:
Other:
Also, .navigate2
is the preferred method.
If the page is slow loading you may need a loop until element present.
Option Explicit
Public Sub AcessaPaginaDados()
Dim xobj As HTMLDivElement
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate2 "https://www.google.com/"
While .Busy Or .readyState < 4: DoEvents: Wend
Set xobj = .document.querySelector("[title=Search]")
xobj.Value = "teste"
Stop
.Quit
End With
End Sub
edited Nov 22 '18 at 14:15
answered Nov 22 '18 at 14:01


QHarrQHarr
34.1k82044
34.1k82044
Tried your code and got the same error on Set xobj = .document.querySelector("[title=Search]")
– Rafael Torres
Nov 22 '18 at 14:12
Did you check what your html gives as the title attribute value? If it doesn't say Search and says something like Buscar then you need to change to [title=Buscar]
– QHarr
Nov 22 '18 at 14:13
If the page is slow loading you may need a loop until element present. If you can confirm what the title value is for the attribute and that it still doesn't work I will add loop code in above.
– QHarr
Nov 22 '18 at 14:16
1
Thank you everyone! @QHarr I updated the code with your solution and it worked like a charm. My local value was[title=Pesquisar]
– Rafael Torres
Nov 22 '18 at 16:08
add a comment |
Tried your code and got the same error on Set xobj = .document.querySelector("[title=Search]")
– Rafael Torres
Nov 22 '18 at 14:12
Did you check what your html gives as the title attribute value? If it doesn't say Search and says something like Buscar then you need to change to [title=Buscar]
– QHarr
Nov 22 '18 at 14:13
If the page is slow loading you may need a loop until element present. If you can confirm what the title value is for the attribute and that it still doesn't work I will add loop code in above.
– QHarr
Nov 22 '18 at 14:16
1
Thank you everyone! @QHarr I updated the code with your solution and it worked like a charm. My local value was[title=Pesquisar]
– Rafael Torres
Nov 22 '18 at 16:08
Tried your code and got the same error on Set xobj = .document.querySelector("[title=Search]")
– Rafael Torres
Nov 22 '18 at 14:12
Tried your code and got the same error on Set xobj = .document.querySelector("[title=Search]")
– Rafael Torres
Nov 22 '18 at 14:12
Did you check what your html gives as the title attribute value? If it doesn't say Search and says something like Buscar then you need to change to [title=Buscar]
– QHarr
Nov 22 '18 at 14:13
Did you check what your html gives as the title attribute value? If it doesn't say Search and says something like Buscar then you need to change to [title=Buscar]
– QHarr
Nov 22 '18 at 14:13
If the page is slow loading you may need a loop until element present. If you can confirm what the title value is for the attribute and that it still doesn't work I will add loop code in above.
– QHarr
Nov 22 '18 at 14:16
If the page is slow loading you may need a loop until element present. If you can confirm what the title value is for the attribute and that it still doesn't work I will add loop code in above.
– QHarr
Nov 22 '18 at 14:16
1
1
Thank you everyone! @QHarr I updated the code with your solution and it worked like a charm. My local value was
[title=Pesquisar]
– Rafael Torres
Nov 22 '18 at 16:08
Thank you everyone! @QHarr I updated the code with your solution and it worked like a charm. My local value was
[title=Pesquisar]
– Rafael Torres
Nov 22 '18 at 16:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432490%2fwhy-my-google-search-macro-is-returning-error-424-object-required%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What line errors? Is it copied code missing the HTML references used for
xobj
do you have a new version of web browser? Has something changed in the environment since?– Nathan_Sav
Nov 22 '18 at 13:56
On which line is error?
– QHarr
Nov 22 '18 at 13:56
you need to remove the parenthesis here
ie.Navigate ("https://www.google.com/")
– Pᴇʜ
Nov 22 '18 at 14:03
Actually this is part of a big search and fill vba and I find this piece with error. The error line is the Set xobj = ie.document.getElementById("lst-ib")
– Rafael Torres
Nov 22 '18 at 14:11
Removed the parenthesis and used the
[title=Pesquisar]
solution and it worked. Thank you– Rafael Torres
Nov 22 '18 at 16:10