#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 32
Default UserForm Password

I have just inherited a spreadsheet with userform and the vba lines
below (Yes, I happen to a beginner in VBA). The problem I am having
with the userform is that once it pops up, you click on the create
template command button and the program starts. Now the problem is it
doesn't ask you to enter a password even though it has textbox and a
command button to ok this. Please help me explain how I can
incorporate a password in the vb lines below so that everytime a
correct password is entered the program is activated.

Many thanks.


Private Sub cmdCreate_Click()
frmauthorisation.Hide
Call CreateTemplate
Me.lbldone.Caption = "A total of " & iWCount & " workbooks" _
& " containing a total of " & iCCount & " worksheets created."
Me.lbldone.Visible = True
frmauthorisation.Show
End Sub

Private Sub cmdCancel_Click()
Unload frmauthorisation
End Sub

Private Sub cmdOK_Click()
If vPW = sPW Then
Me.cmdcreate.Enabled = True
Else
Me.cmdcreate.Enabled = False
MsgBox "Incorrect Authorisation Code!", vbCritical,
"Authorisation"
End If
End Sub

Private Sub Label1_Click()

End Sub
Private Sub lblDone_Click()

End Sub

Private Sub txtPW_Change()
vPW = Me.txtpw.Text
Me.cmdOk.Enabled = Len(vPW & vbNullString) 0
End Sub

Private Sub UserForm_Initialize()
sPW = Chr$(112) & Chr$(104) & Chr$(79) & Chr$(110) & Chr$(108) &
Chr$(121)
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default UserForm Password

You have a line in the Private Sub cmdOK_Click() routine.
If vPW = sPW Then

It looks like those variables are set somewhere else.

But maybe you could use the same technique:

Private Sub cmdCreate_Click()
frmauthorisation.Hide
If vPW = sPW Then
Call CreateTemplate
Me.lbldone.Caption = "A total of " & iWCount & " workbooks" _
& " containing a total of " & iCCount & " worksheets created."
Me.lbldone.Visible = True
else
msgbox "wrong password"
end if
frmauthorisation.Show
End Sub

But this is just a guess.

Ola2B wrote:

I have just inherited a spreadsheet with userform and the vba lines
below (Yes, I happen to a beginner in VBA). The problem I am having
with the userform is that once it pops up, you click on the create
template command button and the program starts. Now the problem is it
doesn't ask you to enter a password even though it has textbox and a
command button to ok this. Please help me explain how I can
incorporate a password in the vb lines below so that everytime a
correct password is entered the program is activated.

Many thanks.

Private Sub cmdCreate_Click()
frmauthorisation.Hide
Call CreateTemplate
Me.lbldone.Caption = "A total of " & iWCount & " workbooks" _
& " containing a total of " & iCCount & " worksheets created."
Me.lbldone.Visible = True
frmauthorisation.Show
End Sub

Private Sub cmdCancel_Click()
Unload frmauthorisation
End Sub

Private Sub cmdOK_Click()
If vPW = sPW Then
Me.cmdcreate.Enabled = True
Else
Me.cmdcreate.Enabled = False
MsgBox "Incorrect Authorisation Code!", vbCritical,
"Authorisation"
End If
End Sub

Private Sub Label1_Click()

End Sub
Private Sub lblDone_Click()

End Sub

Private Sub txtPW_Change()
vPW = Me.txtpw.Text
Me.cmdOk.Enabled = Len(vPW & vbNullString) 0
End Sub

Private Sub UserForm_Initialize()
sPW = Chr$(112) & Chr$(104) & Chr$(79) & Chr$(110) & Chr$(108) &
Chr$(121)
End Sub


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password Userform help !!!! K1KKKA Excel Discussion (Misc queries) 4 January 10th 07 03:09 PM
Userform Jeff Excel Discussion (Misc queries) 0 February 6th 06 09:30 PM
userform carwincarber New Users to Excel 0 October 23rd 05 06:59 PM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM
bypass password when update linking of password protected file Yan Excel Discussion (Misc queries) 1 February 7th 05 11:29 PM


All times are GMT +1. The time now is 07:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"