PDA

View Full Version : UserNames and Passwords



drana325
05-21-2016, 11:03 AM
Hello I have an excel sheet with 50 names and passwords.

Is there a way that i can read the usernames and passwords from excel through powerpoint.

So here's what i have... The User enters their name in an Input box.

the next screen shows UserID and Password.

the User has to enter their userID and Password within the textboxes.
If the UserID and Password matches with the Username then they advance to the next slide

I was inputting them in powerpoint,

as this But i can't add more... (i'm really new to this) :




Sub TextBoxResults1()

If UserName = "Dimple" _
And Slide1.TextBox3.Text = "999" _
And Slide1.TextBox4.Text = "Password" _
And Slide1.TextBox5.Text = "" _
Or _
UserName = "TaLe" _
And Slide1.TextBox3.Text = "702" _
And Slide1.TextBox4.Text = "12368797" _
And Slide1.TextBox5.Text = "" _
Or _
UserName = "Hector" _
And Slide1.TextBox3.Text = "519" _
And Slide1.TextBox4.Text = "12368798" _
And Slide1.TextBox5.Text = "" _
Or _
UserName = "Jason" _
And Slide1.TextBox3.Text = "446" _
And Slide1.TextBox4.Text = "12345684" _
And Slide1.TextBox5.Text = "" _
Or _
UserName = "Sari" _
And Slide1.TextBox3.Text = "695" _
And Slide1.TextBox4.Text = "12368799" _
And Slide1.TextBox5.Text = "" _
Or _
UserName = "Rana" _
And Slide1.TextBox3.Text = "505" _
And Slide1.TextBox4.Text = "12368800" _
And Slide1.TextBox5.Text = "" _
Or _
UserName = "VuDo" _
And Slide1.TextBox3.Text = "716" And _
Slide1.TextBox4.Text = "12368801" _
And Slide1.TextBox5.Text = "" _

Then
Call TextBoxCorrect66
Else
Call TextBoxWrong66
End If


End Sub


is there anyway to make this shorter and read the username, id, and password from the xls file?

SamT
05-23-2016, 08:34 AM
TextBox3 is the UserID, TextBox4 is their password, but what is TextBox5 and why check it?


excel sheet with 50 names and passwordsWhere are the UserID's stored?

SamT
05-23-2016, 09:07 AM
There are many ways to do this, but for someone just starting to code in VBA, I would go with very simple logic.

In VBA, right Click the VBA Project and Insert a Standard Module, Name it "modAuthUsers"

Note that I don't usually code in PowerPoint, so you will have to work with this to perfect it. It is really just common VBA code with PP Textboxes thrown in.

Option Explicit

PublicType AuthUser
ID as String
PW as String
End Type

Public AuthorizedUsers As Collection

Sub Initialize_AuthorisedUsers()

Dim IdPw As AuthUser

With AuthorizedUsers

'Dimple
IdPw.ID = "999"
IdPw.PW = "password"
.Add "Dimple", IdPw

'TaLe
IdPw.ID = "702"
IdPw.PW = "1234567"
.Add "Dimple", IdPw

'Hector
IdPw.ID = "519"
IdPw.PW = "1234568"
.Add "Dimple", IdPw

'Continue Editing values for al fifty users
IdPw.ID = "999"
IdPw.PW = "password"
.Add "Dimple", IdPw


IdPw.ID = "999"
IdPw.PW = "password"
.Add "Dimple", IdPw


IdPw.ID = "999"
IdPw.PW = "password"
.Add "Dimple", IdPw


IdPw.ID = "999"
IdPw.PW = "password"
.Add "Dimple", IdPw

.
.
.
End With
End Sub

You must add this line to the Presentation_Open sub

Initialize_AuthorisedUsers

Now the Code to check all Users is

Sub CheckUsers()
Dim GoodId As Boolean
dim GoodPW As Boolean

With AuthorizedUsers(UserName).Item
GoodId = .ID = Slide1.TextBox3.Text
GoodPW = .PW = Slide1.TextBox4.Text
End With

If GoodID And GoodPW Then
Call TextBoxCorrect66
Else
Call TextBoxWrong66
End If
End sub