Pessoal, vocês teriam alguma dica de como melhorar o código abaixo?
Sou leigo e estou estudando VBA, aceito qualquer sugestão no assunto!
Código: Selecionar todos
Sub Cotação()
Dim MyDate
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = False
.NAVIGATE ("https://servicos.gollog.com.br/Home/Inicio#cotacao")
While .Busy Or .ReadyState <> 4:
Application.Wait TimeSerial(Hour(Now), Minute(Now), Second(Now) + 1)
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
While .Busy Or .ReadyState <> 4:
Application.Wait TimeSerial(Hour(Now), Minute(Now), Second(Now) + 1)
DoEvents:
Wend
.Visible = True
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
objElement.Click
Exit For
End If
Next objElement
End With
Invalido:
MsgBox "Valor disponível"
End Sub