VBA login to site

bensonsearch

Well-known Member
Joined
May 26, 2011
Messages
844
Hi All,
I can not get the below to work, the logins are the right ones feel free to use as not a problem

Code:
Dim oHTML_Element As IHTMLElement
Dim sURL As String
'On Error GoTo Err_Clear
sURL = "[URL]http://www.abbyyonline.com/en/Account/LogOn[/URL]"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
'oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True
Do
' Wait till the Browser is loaded
Loop Until oBrowser.READYSTATE = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.document
    
    ie.document.all.Item(UserName).Value = "[EMAIL="nickolas.benson@gordongotch.com.au"]nickolas.benson@gordongotch.com.au[/EMAIL]"
    ie.document.all.Item("password").Value = "Benson14"
'HTMLDoc.all.Email.Value = "[EMAIL="nickolas.benson@gordongotch.com.au"]nickolas.benson@gordongotch.com.au[/EMAIL]"
'HTMLDoc.all.passwd.Value = "Benson14"
For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
Next
' oBrowser.Refresh ' Refresh If Needed
'Err_Clear:
'If Err <> 0 Then
'Debug.Assert Err = 0
'Err.Clear
'Resume Next
'End If

the code never enters the info
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
You have a lot of variables you are trying to use which haven't been declared or given a value.

For example ie, which you seem to be trying to use when referencing the IE.

Isn't IE referenced by oBrowser?



Anyways, try this.
Rich (BB code):
Dim oHTML_Element As IHTMLElement
Dim sURL As String
'On Error GoTo Err_Clear
sURL = "http://www.abbyyonline.com/en/Account/LogOn"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
'oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True
Do
' Wait till the Browser is loaded
Loop Until oBrowser.READYSTATE = READYSTATE_COMPLETE
Set htmldoc = oBrowser.document
    
    htmldoc.getElementById("username").Value = "nickolas.benson@gordongotch.com.au"
      htmldoc.getElementById("password").Value = "Benson14"

PS Why not use the ID of the login/Submit button?


PPS The ID isn't Login but something close to it.
 
Upvote 0
Hey,
Thanx for your help, it now fills the login details but the log in button goes from red (pushable) to grey. i have to manually go between the email and password fields with the mouse to change, any ideas?

thank you again
 
Upvote 0
Did you try my suggestion for the login button?

Did it not work?
 
Upvote 0
Try this:
Rich (BB code):
Dim sURL As String
    'On Error GoTo Err_Clear
    sURL = "http://www.abbyyonline.com/en/Account/LogOn"
    Set oBrowser = New InternetExplorer
    oBrowser.Silent = True
    'oBrowser.timeout = 60
    oBrowser.navigate sURL
    oBrowser.Visible = True
    Do
        ' Wait till the Browser is loaded
    Loop Until oBrowser.READYSTATE = READYSTATE_COMPLETE
    Set htmldoc = oBrowser.document
    htmldoc.getelementbyid("username").Value = "nickolas.benson@gordongotch.com.au"
    htmldoc.getelementbyid("password").Value = "Benson14"
    Set chk = htmldoc.getElementsByName("rememberme")(0)
    chk.Click
    htmldoc.getelementbyid("Submit").Click
 
Upvote 0
It shouldn't be too hard to navigate to that page but the uploading of files might be difficult.

I've only had a quick look but it looks like there's a file input control involved.

So far I've never seen a way in VBA to enter values to a control like that.

You can't even enter them manually, you have to use the Upload... button which then shows a file dialog.

Do you know if there's any other way to upload files?

For example with some file-sharing sites you can just email what you want to upload as an attachment.
 
Upvote 0
Hi,
Nah i think thats the only way. I managed to get to the upload screen with the below:

Code:
Dim oHTML_Element As IHTMLElement
Dim sURL As String
'On Error GoTo Err_Clear
sURL = "[URL]http://www.abbyyonline.com/en/Account/LogOn[/URL]"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
'oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True
Do
' Wait till the Browser is loaded
Loop Until oBrowser.READYSTATE = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.document
    
   
HTMLDoc.getElementById("username").Value = "[EMAIL="nickolas.benson@gordongotch.com.au"]nickolas.benson@gordongotch.com.au[/EMAIL]"
HTMLDoc.getElementById("password").Value = "Benson14"

Set chk = HTMLDoc.getElementsByName("rememberme")(0)
    chk.Click
    chk.Click
    HTMLDoc.getElementById("Submit").Click
Do
  ' Wait till the Browser is loaded
Loop Until oBrowser.READYSTATE = READYSTATE_COMPLETE
Application.Wait (Now() + TimeValue("00:00:04"))
oBrowser.navigate ("[URL]http://finereader.abbyyonline.com/en/Task/Queue[/URL]")
Do
  ' Wait till the Browser is loaded
Loop Until oBrowser.READYSTATE = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.document
[COLOR=red]HTMLDoc.getElementById("theFile").Click[/COLOR]

but I cant even make the dialog open (im happy to use sendkeys for that) but i dont know. The error i got is: Object variable or with block variable not set.
that on the red line
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,291
Members
448,564
Latest member
ED38

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