Link to home
Start Free TrialLog in
Avatar of thenelson
thenelson

asked on

Programmatically fill in an IE popup login form

I know how to fill in a login on a web page:
   IE.Document.loginForm("username").Value = "1234"
   IE.Document.loginForm("userpassword").Value = "password"

Using VBA, how do I programmatically fill in the user name and password on a popup login form like the one in the attached image?
Screen-Capture.gif
Avatar of vahiid
vahiid
Flag of Afghanistan image

I would just use sendkeys:

set shell = createobject("wscript.shell")
shell.sendkeys "username"
shell.sendkeys "{TAB}"
shell.sendkeys "password"

if you know the title of your window, try bringing it to front by:
success = shell.appactivate("Window Title)
if success then shell.sendkeys "....."
...
...
Avatar of thenelson
thenelson

ASKER

Thanks for the response. I will save send Keys as a last resort. Probably won't work here since I am keeping IE's visibility set to false.

Let's see if anyone else has a better idea. ...
How about simply encoding it as you would on the command line?

Substitute username & pw in the code.

Chris
Sub Q24838887()
Dim strAddress As String
Dim objIE As Object
 
 
    strAddress = "username:pw@ftp://thenelson.name"
    On Error Resume Next
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Visible = False
    objIE.Navigate2 strAddress
    
    'Need to get past logon page to test the links on the next page for workability
    Do While objIE.readystate <> 4
        DoEvents
    Loop
   
    objIE.Visible = True
End Sub

Open in new window

thenelsonuser:Password@ftp://thenelson.name/
did not work. (I was so hopeful).
Using that format on the command line:
"C:\Program Files\Internet Explorer\iexplore.exe" "thenelsonuser:Password@ftp://ftp.thenelson.name/"
also did not work. (did not find the website.)
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"ftp://thenelsonuser:Password@thenelson.name"
also did not work.  It returned in IE:
FTP root at thenelson.name
To view this FTP site in Windows Explorer, click Page, and then click Open FTP Site in Windows Explorer

When I did that, I got the popup login again. Perhaps "ftp://username:pw@thenelson.name" worked with earlier versions of IE.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
rejoinder:

If you check 25651038 & 25651316 you will see that didn't work ;o)

Chris
For some reason
ftp://usernamehere:passwordhere@serveripaddresshere
didn't work then but does work now.

So I have one way to solve this. I guess I'll leave this open for a little longer to see if there is any other solution.
Glad to see that you are up and running.
Eee bah gum ... perhaps there was a typo or stray control character

Chris
It was an FM circuit error:

One time I picked up an aircraft radio after repair, I asked the tech, "What was wrong with it?"  He replied, "Probably something in the FM circuit."  Confused, I asked,"Don't aircraft radios use AM?"  He smiled and replied, "The 'M' stands for magic."
I have a long background in the air force ... our experience with problems is it was usually the seat to stick interface at fault ... Now I simply have to hope you're not a pilot!

Chris
Never heard that one before, I like it!
Thanks guys.

(I am a pilot.)
Oops!  ;o)

Glad we got there in the end though I wish we knew what went wrong the first time.

Chris