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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,215,482
Messages
6,125,060
Members
449,206
Latest member
Healthydogs

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