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
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