Automation Error : unspecified Error

Loganayaki

New Member
Joined
May 3, 2017
Messages
1
Hi,

I am writing the excel vba code for Login functionality. Somehow i have searched this forum and written the code. But i am getting "Automation error: Unspecified error". Please help me to resolve this .
When i do debug the yellow marker show the line "Set doc = IE.Document " which is red marked in code below . I am using 2010 excel and added HTML library and Internet controls library under tools -> preference

Code:
Option ExplicitSub CommandButton1_Click()


Const cURl = "Replaced with My URL "
Const cUsername = "My username"
Const cPassword = "Mypwd"


Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim Loginform As HTMLFormElement


Dim UsernameInputBox As HTMLInputElement
Dim PasswordInputBOx As HTMLInputElement
Dim SigninButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement


If IE Is Nothing Then Set IE = New InternetExplorer
IE.Visible = True
IE.navigate cURl


Do While IE.Busy
Loop
Do While IE.readyState = READYSTATE_COMPLETE
Loop


[COLOR=#ff0000]Set doc = IE.Document[/COLOR]


Set Loginform = doc.forms(0)
Set UsernameInputBox = Loginform.elements("USERID")


UsernameInputBox.Value = cUsername




Set PasswordInputBOx = Loginform.elements("user_pwd")


PasswordInputBOx.Value = cPassword


Set SigninButton = Loginform.elements("fc_sbmit")


SigninButton.Click


Do While IE.Busy


  Loop


  Do While IE.readyState = READYSTATE_COMPLETE
  


  Loop
Set doc = IE.Document




End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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