PDA

View Full Version : multiple selection of interrogative sentences in word document



anielo
12-31-2015, 12:22 PM
Hi there;
I need a code which searches for multiple question form sentences in a word document and selects (not highlights) all of them at once!
I am a newbie and I would be so grateful for any help
thanks

gmaxey
12-31-2015, 01:39 PM
Can't be done. The Word VBA object model does not recognized discontinuous selections and can't make them either.

anielo
12-31-2015, 01:48 PM
Dear Greg;
many thanks for your quick reply.
cheers

gmaxey
01-01-2016, 06:55 AM
Anielo,

I hope that you get a notification that I've posted again. Actually, while perhaps bit crude, there may be a way to do this. If you apply a unique style to the text you want selected then this might work. Here the unique style is body text:


Sub SelectDiscontinuousRanges()
Dim oPar As Paragraph
Dim oEd As Editor
With ActiveDocument
For Each oPar In .Paragraphs
If oPar.Range.Style = "Body Text" Then
Set oEd = oPar.Range.Editors.Add(wdEditorEveryone)
End If
Next
.SelectAllEditableRanges (wdEditorEveryone)
.DeleteAllEditableRanges (wdEditorEveryone)
End With
lbl_Exit:
Exit Sub
End Sub

anielo
01-01-2016, 07:53 AM
dear Greg;
thank you for your reply.
I do really appreciate your help.
best wishes