Boa noite,
Pessoal, gostaria da ajuda de voces com um código..
O código abaixo não está clicando com o mouse no botão "Cadastrar"
------Set objElementCol = IE.document.getElementsByTagName("input")
For Each objElement In objElementCol
If objElement.Value = "Cadastrar" Then
bjElement.Click-------
O comando não da erro, mas também não acontece nada!
Por gentileza, vocês teriam uma forma de contornar isso?
Segue código completo:
Sub Cotação()
Dim MyDate
Dim IE As Object
Set IE = CreateObject("InternetExplorer.application")
With IE
.Visible = True
.NAVIGATE ("https://servicos.gollog.com.br/Home/Inicio#cotacao")
While .Busy Or .readyState <> 4:
DoEvents:
Wend
IE.document.getElementById("select_data").Value = Range("F8")
IE.document.getElementById("input_cotacao").Value = Range("C6")
IE.document.getElementById("input_destino").Value = Range("C22")
IE.document.getElementById("input_cotacao_2").Value = ("1")
IE.document.getElementById("input_destino_1").Value = Range("C8")
IE.document.getElementById("select_produto").Value = Range("F6")
IE.document.getElementById("input_entrega").Click
Set target = Range("G15")
If target.Value = "SIM" Then
IE.document.getElementById("input_valor_nota").Value = Range("F15")
IE.document.getElementById("input_seguro").Click
End If
IE.document.getElementById("quote").Click
On Error GoTo Invalido
IE.document.getElementById("input_name").Value = ("Marcos")
IE.document.getElementById("input_phone").Value = ("(99) 9999-99999")
IE.document.getElementById("input_email").Value = ("marcos.abreu@spharmu.com.br")
IE.document.getElementById("input_company").Value = ("SPecial Pharmus")
Dim objElementCol As Object
Dim objElement As Object
Set objElementCol = IE.document.getElementsByTagName("input")
For Each objElement In objElementCol
If objElement.Value = "Cadastrar" Then
bjElement.Click
Exit For
End If
Next objElement
Invalido:
MsgBox "Valor disponível"
While .Busy Or .readyState <> 4:
DoEvents:
Wend
End With
End Sub
Vídeo recomendado
https://youtu.be/diWPPPhW-9E
https://youtu.be/diWPPPhW-9E
Clicar com o mouse ou apertar enter
-
- Colaborador
- Mensagens: 15
- Registrado em: Sex Nov 22, 2019 9:28 am
Re: Clicar com o mouse ou apertar enter
Boa tarde,
Tenta usar o Sendkeys para enviar o comando de ENTER.
Ex: SendKeys "{ENTER}", True
Para clicar copia o seguinte código:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseonds As Long)
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10
Sub SingleClick()
SetCursorPos 25, 30 'x and y position
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
'SetCursorPos 100, 100 'x and y position
'mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Private Sub DoubleClick()
'Double click as a quick series of two clicks
SetCursorPos 100, 100 'x and y position
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
'Double click as a quick series of two clicks
'SetCursorPos 100, 100 'x and y position
'mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Sub RightClick()
'Right click
SetCursorPos 200, 200 'x and y position
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
' SetCursorPos 200, 200 'x and y position
'mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
End Sub
Tenta usar o Sendkeys para enviar o comando de ENTER.
Ex: SendKeys "{ENTER}", True
Para clicar copia o seguinte código:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseonds As Long)
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10
Sub SingleClick()
SetCursorPos 25, 30 'x and y position
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
'SetCursorPos 100, 100 'x and y position
'mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Private Sub DoubleClick()
'Double click as a quick series of two clicks
SetCursorPos 100, 100 'x and y position
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
'Double click as a quick series of two clicks
'SetCursorPos 100, 100 'x and y position
'mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Sub RightClick()
'Right click
SetCursorPos 200, 200 'x and y position
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
' SetCursorPos 200, 200 'x and y position
'mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
'mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
End Sub