VBA Set ie = CreateObject ("InternetExplorer.Application")


Next, I'm picking up VBA to navigate a web page (can be with Internet Explorer)

I basically found some codes with the CreateObject("InternetExplorer.Application") method. But I can not input the fields using the object ID to be able to log in to the page.

I need to login to the page using id="username" and id="passwd" , enter the site (which would be another page obviously) and inside the site click on another button.

I know the name of the objects because I looked at the source code of the site, but I do not know if this is all possible, or if I have to store the current location in a variable. It is possible? How do I?

asked by anonymous 20.08.2014 / 03:13

2 answers


Yes, it is possible.

' Cria um novo objecto do IE
Set IE = CreateObject("InternetExplorer.Application") 
Set WshShell = WScript.CreateObject("WScript.Shell")  

' Indica ao IE que deve navegar para a página
IE.Navigate "http://aminhapagina.com" 
IE.Visible = True 

' Loop de espera até o IE carregar a página
Do while IE.Busy
  WScript.Sleep 100

' Preenche os campos necessários
IE.Document.All.Item("username").Value = "username" 
IE.Document.All.Item("password").Value = "password"

' Invoca a função clique do botão de salvar

In this way, after clicking the button and if successful and navigating to the next page, just apply the same logic, look for the button you need with IE.Document.All.Item(...) and invoke the Click function.

20.08.2014 / 13:41

Did you solve your problem?

If you do not see if this helps!

Look at the source code of the page and see if you have a tag called (Frame or Frameset), if you have this problem, because you manipulate IE, it manipulates by screen or by the tag that are sub divided for div and for these frames, to be able to manipulate the events that are contained in these frames you should only inform the VBA where and what frame the object is!

IE.Document.frames(0).Document.all("username").innertext = "username"
IE.Document.frames(0).Document.all("senha").innertext = "senha"

If it did not work let me know!

04.05.2018 / 20:46