VBA Set ie = Createobject("Internetexplorer.Application")

Asked

Viewed 8,784 times

3

Next, I’m picking up from VBA to browse a web page (can be with Internet Explorer)

Basically I found some codes with the Method CreateObject("InternetExplorer.Application"). However, I cannot input the fields using the object ID to log into the page.

I need to login to the page using id="username" and id="passwd", click the button id=". save", 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 don’t know if all this is possible, or if I have to store the current location in a variable. Is that possible? How do I?

2 answers

4

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
Loop

' 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
IE.Document.All.Item(".salve").Click

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

1

managed to solve his problem?

if you don’t see if this helps!

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

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

If it didn’t work, let me know!

Browser other questions tagged

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