View Single Post
 
Old 03-17-2017, 03:40 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The line in question writes the text from the content control to a customdocument property called "Sbjct". If that document property doesn't exist you will get an error (hence the comment two lines before this one).

Alternatively you could change the document property references to document variables (and use docvariable fields to display the variable content) e.g.
Code:
Case "Sbjct": ActiveDocument.Variables("Sbjct").Value = ContentControl.Range.Text
This doesn't require the variable to pre-exist but it will crash if the content control is empty so you need to trap that (and the default text) e.g.
Code:
Case "Sbjct"
                If Not ContentControl.Range.Text = "" _
                   And Not ContentControl.Range.Text = ContentControl.PlaceholderText Then
                    ActiveDocument.Variables("Sbjct").Value = ContentControl.Range.Text
                End If
You will of course have to treat all those documentproperty entries similarly
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote