Thread: [Solved] Schrödinger's paragraph
View Single Post
 
Old 12-03-2024, 06:50 PM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

It is just a empty paragraph that Microsoft has pressed a placeholder role on.


Select your empty paragraph in the CC and step through this code:

Code:
Sub SSM()
Dim oCC As ContentControl
Dim oPar As Paragraph
Dim oRng As Range
Dim lngIndex As Long
  Set oCC = ActiveDocument.SelectContentControlsByTitle("ccTitle").Item(1)
  MsgBox oCC.Range.Paragraphs.Count
  'Select the empty paragraph that appears to be in the CC.  Is it really there?
  MsgBox Selection.InRange(oCC.Range)
  'No.  Try to delete it.
  Selection.Range.Delete
  'You can't. Why?
  'Show the tags. Notice the selection shift
  oCC.Appearance = wdContentControlTags
  'It is smoke and mirrors.  The empty paragraph is the placeholder for the XML tags
  For lngIndex = ActiveDocument.Paragraphs.Count To 1 Step -1
    If Selection.Range.InRange(ActiveDocument.Paragraphs(lngIndex).Range) Then
      ActiveDocument.Paragraphs(lngIndex).Range.Delete
    End If
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote