I have a TextBox called "txtExplanation", which is used to populate a Content Control of the same name in my document.
What I'm trying to achieve is the removal of any excess paragraphs that might be present within the TextBox. So in effect only a single paragraph is present between blocks of text and potential empty paragraphs removed after the last sentence.
I'm currently getting an "Invalid or unqualified reference" on this line
oRng.Text = .txtExplanation.Text
Here is what I am trying to use. Of course it's possible that I'm approaching this the wrong way!
Sub RemoveEmptyParagraphs()
Dim occ As ContentControl
Dim oRng As Range
Dim oCtrl As control
Dim intCounter As Integer
Set oRng = occ.Range
oRng.Text = .txtExplanation.Text
' Set a range to the content control
Set oRng = ActiveDocument.SelectContentControlsByTag("Explanation").Item(1).Range
' Fill the range with the content of the text box
oRng.Text = oCtrl.Text
' Remove any empty paragraphs after last entered text
intCounter = 1
Do
oRng.Paragraphs.Last.Range.Characters.Last.Delete
intCounter = intCounter + 1
' Setting this to five should cater for the most extreme example
Loop Until intCounter >= 5
lbl_Exit:
Exit Sub
End Sub