![]() |
#1
|
|||
|
|||
![]()
Hi everyone,
maybe I am overlooking something very obvious... but, as the topic suggests I have a problem with paragraphs that appear to both exist and not to exist at the same time. The problem occurs always when when there is an empty paragraph at the end of a content control. I am looking for a way to target this paragraph efficiently and remove it. My problem is mainly that I cannot find a way to target these paragraphs directly for whatever reason! I've built a small example to demonstrate my problem: Lets say I have a content control cc in that one can select three paragraphs (screenshot) of which the last one is empty. The test document looks like this: ![]() It has 6 paragraphs in total of which 2 are placed before the content control, three are or lets say should be within the cc and one is/should be after the cc. The cc is a rich text cc, if that matters. When I run the code Code:
Sub countParasInCC() Dim doc As Document, cc As ContentControl, ccRange As Range, paraCountCC As Integer, myccTitle As String Set doc = ActiveDocument myccTitle = "ccTitle" Set cc = doc.SelectContentControlsByTitle(myccTitle).Item(1) Set ccRange = cc.Range paraCountCC = ccRange.Paragraphs.Count End Sub However, when i run the code Code:
Sub countParasDocument() Dim doc As Document, paraCountDoc As Integer Set doc = ActiveDocument paraCountDoc = doc.Range.Paragraphs.Count End Sub Can somebody explain to me why the empty paragraph is not counted when counting paragraphs in the cc's range but is counted when counting paragraphs in the document range? What is the method to target and remove such paragraphs? Many thanks in advance! |
Tags |
content control, delete empty, paragraphs |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
laith93 | Word VBA | 7 | 04-27-2022 08:26 AM |
a macro to replace paragraph mark with a space applies effect on paragraph marks after the selection | drrr | Word VBA | 2 | 08-24-2021 03:05 AM |
Inserting text from a Userform into a Field in a paragraph in a paragraph in a word document | storemaz | Word VBA | 1 | 03-13-2020 08:11 AM |
![]() |
Pinesh | Word | 2 | 03-09-2018 04:24 PM |
![]() |
windhoek2010 | Word | 1 | 09-15-2017 08:30 PM |