Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    May 2001
    Location
    NJ
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find/Replace across field boundaries (Word 2000, sr1a)

    Is it possible to find a piece of text that crosses a field boundary?

    Here's the situation: I'm working with a Word add-in (EndNote), which is formatting citations and footnote references. Under certain circumstances EndNote messes up formatting in a predictable way, leaving me with, e.g., '.).,' [where the '.).' is inside the field, and the trailing ',' is outside it]. I need to search for the '.,', but despite the appearance of proximity, the field boundary lies between them.

    I can find the field; I can find text entirely in the field; I can find text outside the field; but I can't find text across the boundary.

    Any answers (or creative suggestions) from the experts?

  2. #2
    sgregg
    Guest

    Re: Find/Replace across field boundaries (Word 2000, sr1a)

    I don't think there is a way to find text which crosses a field boundary in Word, but you could use the following code:

    Sub FixEndNote()
    Dim myRange As Range
    Selection.StartOf wdStory
    With Selection.Find
    .ClearFormatting
    .Text = " ,"
    .Forward = True
    .Execute
    While .Found = True
    Set myRange = Selection.Range
    Selection.Collapse wdCollapseStart
    Selection.MoveRight wdCharacter, -1, wdExtend
    If Selection.Fields.Count > 0 Then
    myRange.Select
    'do what you want here, eg Selection.Delete
    Selection.Collapse wdCollapseEnd
    End If
    .Execute
    Wend
    .Text = ""
    End With
    End Sub

    If you need to stick that " ," within the field result you will require more code.

  3. #3
    Lounger
    Join Date
    May 2001
    Location
    NJ
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find/Replace across field boundaries (Word 2000, sr1a)

    Thanks very much! I'll give it a shot. --Chris

Posting Permissions

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