View Single Post
 
Old 09-14-2020, 01:28 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
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

Yes it would be workable but not particularly flexible. You can only use a bookmark name once so if there are multiple places to remove content then it would require lots of code. Also if the user makes the wrong choice there is no coming back without restarting the doc. I would hide text to make it non-destructive in the event of a bad selection - this does require the user's options set to not show hidden text.

I would be more inclined to use Content Controls and either the Tag or Title property on the dependent text so you can affect more than one text area. If the selection is allowed to show in the document then it could be used instead of a code-based dialog box.

As an example, set up your doc with a dropdown Content Control titled Salesperson and then a bunch of Content Controls which use a title corresponding to one of those entries in Salesperson then code to hide CCs which don't have that title is
Code:
Private Sub Document_ContentControlOnExit(ByVal myCC As ContentControl, Cancel As Boolean)
  Dim aCC As ContentControl, sSales As String
  If myCC.Title = "Salesperson" Then
    sSales = myCC.Range.Text
    For Each aCC In ActiveDocument.ContentControls
      aCC.Range.Font.Hidden = aCC.Title <> sSales  'hide if CC title doesn't match selected salesperson
    Next aCC
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote