Open secure website and paste username and password.

schafers

Board Regular
Joined
Jul 5, 2005
Messages
74
Trying to find a set of code that I can use to open a website that's predetermined, and enter in the users name and password automatically. And if possible, open a new email via the website, addressed to a person, and ready to browse for the file to attach.

The code I have is below.

Private Sub CommandButton1_Click()
'
storenumber = [$c$3]

If [$iv$2] = True Then

If [$iv$3] <> 0 Then

MsgBox ("Can't send with No Adjustments Checked & Items to Adjust, Please clear one")

End
End If
End If

If [$iv$2] = False Then

If [$iv$3] = 0 Then

MsgBox ("Can't send without No Adjustments checked or Items to Adjust")

End
End If
End If

If MsgBox( _
prompt:="Ready to Send Adjustments?", _
Title:="Proceed?", _
Buttons:=vbYesNo) = vbYes Then
Application.ScreenUpdating = False
ActiveSheet.Copy
ActiveSheet.Shapes("CommandButton1").Select
Selection.Delete
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "Store #" & storenumber & " - SEND THIS FILE" & " To Cathy" & ".xls"
Application.DisplayAlerts = True
ActiveWorkbook.Close False
MsgBox ("Please open a new email addressed to Cathy Mandeville, and attach the file named Store #" & storenumber & " - SEND THIS FILE To Cathy.xls")

Else

MsgBox "Please Finish Adjustments"
'user chose not to send file yet
End
End If

ThisWorkbook.Saved = True
ActiveWorkbook.FollowHyperlink Address:="https://webmail.albertsons.com/exchange", _
NewWindow:=True

Application.Quit
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

Thanks for the help in advance.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Sub myWebOpenPW()
'Open site if it requires a PassWord Model!
Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

'Go to this Web Page!
IE.Navigate "http://YourLoggOnPageAddress_GosHere"

'Check for good connection to web page loop!
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop

'Wait for window to open!
Application.Wait (Now + TimeValue("0:00:01"))
'MsgBox "Done"
IE.Visible = True

'Send logg-on information!
'May need additional SendKeys as needed?
'Determine by the actual key-stroks needed!
SendKeys "UserID_GosHere", True
SendKeys "{TAB}", True
SendKeys "PassWord_GosHere", True
SendKeys "{ENTER}", True
End Sub
 
Upvote 0
Thank you, Thank you, Thank You!!! WOOHOOO!!! This is exactly what I'm looking for. Next question, do you know how to tell Explorer to click on certain buttons? I'm using Exchange 2003 for the web, and trying to automate the process for my clients to open a new email, with autopopulating a send to name, and subject line. So all they have to do is browse to where the file is located.

Thanks again for the code, it worked so fast!!
Steven
 
Upvote 0
You use the Send Keys function to replicate any key stroks you would do from the key board!

Like Tabing to a control, hitting Enter for Select, navagating with the Arrow keys, or any others.

Experiment with the KeyBoard not the Mouse to get to where you whant to go!

Then replicate the key steps using SendKeys.
 
Upvote 0
Perfect. Thanks for the help, I'm going to play with it. This is exaclty what i need to make my clients lives easier. Thank goodness that Exchange 2003 doesn't change that much! :) Thanks again for all your help.
Steven
 
Upvote 0
Only problem now, is how do I use the Shift + Tab key at the same time. I can't figure out the code for that piece. Right now I'm using the following:

Sendkeys "{Shift+Tab}", True

And it's returning a error. Thanks again for your help.
Steven
 
Upvote 0
Worked like a champ!! And the tab keys work great! It works just like i need it to!! WOOHOO!! Thanks again.
 
Upvote 0
hello. i have used the code
Sub myWebOpenPW()
'Open site if it requires a PassWord Model!
Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

'Go to this Web Page!
IE.Navigate "http://YourLoggOnPageAddress_GosHere"

'Check for good connection to web page loop!
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop

'Wait for window to open!
Application.Wait (Now + TimeValue("0:00:01"))
'MsgBox "Done"
IE.Visible = True

'Send logg-on information!
'May need additional SendKeys as needed?
'Determine by the actual key-stroks needed!
SendKeys "UserID_GosHere", True
SendKeys "{TAB}", True
SendKeys "PassWord_GosHere", True
SendKeys "{ENTER}", True
End Sub

provided above. It works perfectly! However, I have to navigate through the page, clicking several links to get to wehre i need.... and sendkey works good...but because of the timing issue....it may take 10 seconds to load the one page and 5 for other page.. it is not consistant. Is there anyway to say if the page is finished loading, then do the sendkey?
here is the part of my code:
'GLD
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:10"))
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "%{left}", True
'NWD
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:10"))
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "%{left}", True

i have it to set to wait 5 or 10 seconds. However, it may take more than that.

Thank you!
 
Upvote 0
This works on the IE window, but I don't think it can detect the additional links?

'Check for good connection to web page loop!
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop

I am not sure about testing for the new pages?
Someone else may help us both out?
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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