Use password to log in online, without hard coding it

buorsa

New Member
Joined
Nov 14, 2016
Messages
4
Hi Guys

I have written a code to get directly from the Excel file in a login on a web page. This works well.
However, I dont want my password to be hard coded in the VBA code.
I was thinking about adding password protection to the workbook and when i open it and enter the password it will automaticlly also use this password to log in on the web page. Is this possible, or do you have other ideas on how I could solve my problem

Thanks and Cheers
Luca
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Could you post the code you DO have?

You could just have the password as an input box, but yes, password protecting the workbook would also achieve your goal.
 
Upvote 0
Code:
Sub login()
Dim appIE As Object
Set appIE = CreateObject("Internetexplorer.Application")
appIE.Visible = True
appIE.navigate "website"
    Do: Loop Until appIE.Busy = False
    Do: Loop Until appIE.Busy = False
    
With appIE.document
 .all("userid-input").Value = "username"
 .all("password-input").Value = "password"
 .all("uap-submit-button").Click
 
End With

End Sub
 
Upvote 0
Something like this would work:

Code:
Sub login()
Dim appIE As Object
Dim sPassword As String


sPassword = Application.InputBox("Please Enter Password", "Password Entry")


If sPassword = "False" Then Exit Sub 'user clicked Cancel


Set appIE = CreateObject("Internetexplorer.Application")
appIE.Visible = True
appIE.navigate "website"
    Do: Loop Until appIE.Busy = False
    Do: Loop Until appIE.Busy = False
    
With appIE.document
 .all("userid-input").Value = "username"
 .all("password-input").Value = sPassword
 .all("uap-submit-button").Click
 
End With


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,739
Messages
6,174,217
Members
452,551
Latest member
croud

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