View Single Post
 
Old 03-31-2021, 03:51 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I don't understand why there needs to be multiple steps so my solution may not be what you wanted. I would approach this by making use of checkbox content controls and having a macro check the user logon name to determine how to expand the user details.

This approach then just expects the user to just check a box and then move their cursor in order to see their details replace the checkbox immediately. To me this is much simpler in terms of usability.

I've attached a demo document showing how this is set up. The code that is being used in the file is
Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean)
  Dim sUser As String, sID As String
  sID = Environ$("UserName")
  If aCC.Type = wdContentControlCheckBox Then
    If aCC.Checked Then
      sUser = ExpandUser(sID)
      If sUser <> "" Then
        aCC.Type = wdContentControlText
        aCC.MultiLine = True
        aCC.Range.Text = sUser
      End If
    End If
  End If
End Sub

Function ExpandUser(sID As String) As String
  Select Case sID
    Case "winki", "winkidelegate"
      ExpandUser = "V. d. strokovnega direktorja" & vbCr & "Valentina Winkler Skaza, dr. med., spec. psih."
    Case "mario123"
      ExpandUser = "Pomocnik direktorja za podrocje zdravstvene nege " & vbCr & "Mario Dremšak, mag. manag., dipl. zn."
    Case Else
      Application.StatusBar = "Not a recognised user: " & sID
  End Select
End Function

Sub ResetCheckBoxes()
  Dim aCC As ContentControl
  For Each aCC In ActiveDocument.SelectContentControlsByTag("Signed")
    aCC.Type = wdContentControlCheckBox
    aCC.Checked = False
  Next aCC
End Sub
Attached Files
File Type: docm Demo.docm (32.2 KB, 14 views)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote