PDA

View Full Version : Loop thru selected paragraphs



David of New
01-28-2021, 10:51 AM
I want to format the current selection of paragraphs. I can format a specific paragraph:


Application.ActiveWindow.Selection.ShapeRange.TextFrame2.TextRange.Paragrap hs(1).ParagraphFormat.IndentLevel = 6


and i can format all paragraphs in the textframe


Application.ActiveWindow.Selection.ShapeRange.TextFrame2.TextRange.Paragrap hs.ParagraphFormat.IndentLevel = 6


but not just those selected.

John Wilson
01-29-2021, 08:28 AM
Doesn't this work?


ActiveWindow.Selection.TextRange2.ParagraphFormat.IndentLevel = 6

If you have non contiguous paragraphs selected then I don't know of any way to test for selection in a loop

Maybe you could call e.g. BOLD from CommandBars.ExecuteMso("Bold") and then loop looking for bold text (or whatever)

David of New
01-29-2021, 09:58 AM
Yes, it does, thanks! I knew i had to use TextFrame2 or TextRange2 to get above indent level 5 but found the syntax confounding.

Thanks again.

David