Consulting

Results 1 to 3 of 3

Thread: Password protect content control

  1. #1
    VBAX Regular
    Joined
    Nov 2015
    Posts
    14
    Location

    Password protect content control

    So this is going to be different. I am looking to have either a dropdown combo content control with multiple different names in them. If any of the names are picked I want to have a box to come up and ask for a password that was created by the user with the name. So for example if I had Bob, Jim, and Joe in the drop down box I would like to have each one have a different password attached to each name created by that person. Is there a way to do that? Or is there a way that if I have someone fill in the signature line on my form that it will ask for their password so that way other people cannot type any name in there. Hopefully that makes sense.

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,341
    Location
    This sort of thing would be a walk in the sun if the dimwits at Microsoft would fix the Word Object modules so that it where accessible while in the Content Control content store events. In the meantime you can use the registry:

    You will need to map your "dropdown" content control to an XML part. Put the following code in the ThisDocument module. Run the setup to store the passwords.

    Private Sub Document_ContentControlBeforeStoreUpdate(ByVal ContentControl As ContentControl, Content As String)
      Select Case Content
        Case "Bob"
          If Not GetSetting("Demo", "Passwords", "BobPW") = InputBox("What is  your password") Then
            Content = vbNullString
          End If
        Case "Jim"
          If Not GetSetting("Demo", "Passwords", "JimPW") = InputBox("What is  your password") Then
            Content = vbNullString
          End If
        Case "Joe"
          If Not GetSetting("Demo", "Passwords", "JoePW") = InputBox("What is  your password") Then
            Content = vbNullString
          End If
      End Select
    lbl_Exit:
      Exit Sub
    End Sub
    
    Sub Setup()
      SaveSetting "Demo", "Passwords", "BobPW", "12345"
      SaveSetting "Demo", "Passwords", "JimPW", "54321"
      SaveSetting "Demo", "Passwords", "JoePW", "12321"
    lbl_Exit:
      Exit Sub
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    VBAX Regular
    Joined
    Nov 2015
    Posts
    14
    Location
    Ah ok well I have never worked with XML before. Thank you for the code. I will have to use it later after I figure out how to work with XML and map the content control dropdowns to it. Thank you for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •