Consulting

Results 1 to 5 of 5

Thread: multiple selection of interrogative sentences in word document

  1. #1

    Unhappy multiple selection of interrogative sentences in word document

    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

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    Can't be done. The Word VBA object model does not recognized discontinuous selections and can't make them either.
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Dear Greg;
    many thanks for your quick reply.
    cheers

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    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
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    dear Greg;
    thank you for your reply.
    I do really appreciate your help.
    best wishes

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •