0
Good afternoon! I’m trying to automate the filling of a form for a website, however, I’m having difficulty entering the menu where the form is. It works like this: I login to the site through a userform, where I inform the user and password and click on "login"... until then ok, I was able to do. After logging in, I need to enter a menu that expands when I hover over and it opens other submenus (+ 2 levels). I need to click on the second level of one of these submenus to view the form and I’m not getting the macro to click. I don’t know if I could explain well, I don’t know much about programming. I’ll leave the VBA code. And if you need any more information, let me know. Note: I found this post but it didn’t work in my case: Access menu mouseover by VBA
Sub Robo_apac_1()
Dim IE As InternetExplorer
'Cria um objeto Internet Explorer
Set IE = New InternetExplorer
'Torna o objeto visível
IE.Visible = True
'Navega ao site do SIGA Saúde
IE.Navigate "http://siga.saude.prefeitura.sp.gov.br/sms/login.do?method=logoff"
'Identifica se a página já foi totalmente carregada
While IE.ReadyState <> READYSTATE_COMPLETE
Wend
'aguardar 3 segundos (se necessário)
'sng = Timer
'Do While sng + 3 > Timer
'Loop
IE.Document.All("j_username").Value = frmlogin.txbLogin
IE.Document.All("j_password").Value = frmlogin.txbSenha
IE.Document.All("confirmar").Click
'fehca a tela te login
Unload frmlogin
'aguardar 2 segundos antes de validar o logon
sng = Timer
Do While sng + 2 > Timer
Loop
'verifica se teve exito no login. Caso negativo, avisa o usuário e encerra a macro
i = IE.Document.body.getElementsbytagname("table")
If i Is Nothing Then GoTo continua
If InStr(i.innertext, "Usuário ou senha inválido") > 0 Then
IE.Quit
MsgBox "Usuário ou senha inválido!", vbCritical, "Login"
Exit Sub
End If
continues: Set link = IE.Document.body.getelementsbytagname("a") For Each j In link If j.innertext = "APAC" Then j. Click Exit For End If Next j
End Sub
Edited 17/02:
MENU PRINCIPAL:
<div id="reg" style="left:297;width:100" onmouseover="handleMouseOver(event || evt)" onmouseout="handleMouseOut(event)" onclick="scheduleHideTree2(Tree.getElementNode(this))" class="">
REGULAÇÃO
</div>
NIVEL 1:
<div id="reg_apac" onmouseover="handleMouseOver(event || evt)" onmouseout="handleMouseOut(event)" class="">
APAC
</div>
NIVEL 2:
<div id="reg_preenchimento_solic" onmouseover="handleMouseOver(event || evt)" onmouseout="handleMouseOut(event)" onclick="setUrl(this,' http://siga.saude.prefeitura.sp.gov.br:80/sms/preenchimentoLaudo.do?method=initUseCaseAndInsert&subsystem=apac')" class="">
Preenchimento do Laudo de Solicitação
</div>
Menu image: https://imgur.com/a/tX10HSs
if it is vba, remove the tag of
javascript
– Ricardo Pontual
It depends a lot on the page’s HTML, @Diego. You don’t need to move your mouse to put it on top of the menu, no. These menus are usually an organized set of tags
DIV
,SPAN
,TABLE
and related, which are hidden and have the visibility adjusted as the user points to one or the other. What you can do is look at which HTML element you want to click on, to send an event click to it. Using Chrome, right-click the element, thenInspecionar
. If you haven’t opened in the exact place, repeat the operation. Paste the HTML into the question.– César Rodriguez
Opa Cesar... first, thank you for your attention! I put the HTML code of each menu and submenu, see if this is how Oce requested. I took advantage and uploaded the menu image, marking the one that refers to the HTML codes I pasted. Thank you
– Diego Sanguinete
@Césarrodriguez, good morning! I added an image with the HTML of the beginning... the menu I am trying to access is the "REGULATION". Thank you
– Diego Sanguinete