Clear a form field in vba

J

JayM

I have written the below code on a form click OK
I know you can set a password when saving but we have a Case Management
System which automatically saves the document for you. I need to be able to
set a password.
Firstly I am unsure how to check the password.
Secondly I need the txtPassword field to clear to it isn't there for the
next document.

Any help would be greatly appreciated. Maybe this is already out there and
I didn't need to write all this.

Private Sub cmdOK_Click()
Dim xPassword As String

xPassword = txtPassword

With ActiveDocument
.ReadOnlyRecommended = False
.Password = xPassword
.WritePassword = ""
.RemovePersonalInformation = False
.RemoveDateAndTime = False
End With
frmPassword.Hide
MsgBox "Your Password '" & xPassword & "' has been set", vbOKOnly


End Sub
 
D

Doug Robbins - Word MVP

Create an Activate event for the form containing

txtPassword.Text = ""

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

JayM

Doug

Thanks for the response. i should have said that I am a novice when it
comes to coding. having used things from macros I have recorded previously
to write this one.

How do i go about creating an activate event?

JayM
 
D

Doug Robbins - Word MVP

Private Sub UserForm_Activate()
txtPassword.Text = ""
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top