Fill in combobox on web page via VBA

Asked

Viewed 222 times

0

I am trying through VBA in Excel, fill a combobox on a website.

But when I run the code, that error message comes up saying that "the object does not accept this property or method". The part of the HTML code of the website is this:

inserir a descrição da imagem aqui

The Combobox I need to fill is type "text", and I will insert a zip code:

inserir a descrição da imagem aqui

My code is written like this:

IE.Document.getElementByName("zipcode").innertext = "13214661"

I’ve already altered it, trying to use the document.all, document.GetElementByID, document.GetElementByClass, etc. Anyway, even not knowing HTML, I made some attempts. Someone can help me?

1 answer

1

Add a time using Sleep before attempting to insert the zip code. outside the functions, preferably at the top type:

Declare Ptrsafe Sub Sleep Lib "kernel32" (Byval dwMilliseconds As Long)

And within the code, above the line : IE.Document.getElementByName("zipcode"). innertext = "13214661"

Put Sleep 1000 '1 second time

For some reasons you may have tried searching for the element without having finished loading the page.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.