VBA to click on a button

LuliC

New Member
Joined
Nov 26, 2018
Messages
1
Hi!

I want to login in a website, but first i have to select an option, and i'm not being successful.
This is the website: https://servicosonline.cpfl.com.br/agencia-webapp/#/login
And i want to select "cnpj". Can somebody help me? thanks
The code that i am using:



Dim htmlDoc As HTMLDocument
Dim oBrowser As InternetExplorer


Sub Login()


Dim oHTML_Element As IHTMLElement
Dim sURL As String
On Error GoTo Err_Clear
sURL = "https://servicosonline.cpfl.com.br/agencia-webapp/#/login"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True


Do
Loop Until oBrowser.readyState = READYSTATE_COMPLETE




Set htmlDoc = oBrowser.document


IE.document.getElementById("SelectCnpj").Click

htmlDoc.all.DocumentoCnpj.Value = "cnpj"
htmlDoc.all.seuCodigo.Value = "UC"




For Each oHTML_Element In htmlDoc.getElementsByTagName("input")
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For


Next
Err_Clear:


Resume Next
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top