Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Macro for search and replace

    I need to check whether a name is in the bibliography at the end of a document.

    If I highlight a name, copy it, split the window, go to the end of the document in the second half of the document,and then try to make a backwards search using the copied name, the macro recording button will not respond.

    Any suggestions?

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,846
    Thanks
    0
    Thanked 175 Times in 161 Posts
    I'm not sure why you'd need a macro for this, as pressing Ctrl-F and inputting the name will flag all locations at which it appears, including in the bibliography if it's there.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  4. #3
    New Lounger
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks. You are right of course in Word 2013. I should have said I was working in Word 2003, where I have many working macros that I cannot transfer to Word 2013.

  5. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,846
    Thanks
    0
    Thanked 175 Times in 161 Posts
    Even in Word 2003, clicking on the Find dialogue's 'Highlight all terms found in' option and using 'Find all' will highlight all matching terms in the selected portion of the document. It would be a simple matter to scroll from there to the end of the document, which I assume is where the bibliography would be found (assuming the document has one). And, since Word 2003 doesn't support the bibliography field of Word 2007 & later, how is a macro to identify whether anything it finds is part of a bibliography?
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. #5
    New Lounger
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    The bibliography is at the end of the document, not in a bibliography field.

    Macros disable the search and find commands. I just wanted a macro whereby I could with one click bring up the first instance of a name I had highlighted in the text using a backwards search from the end of a long document.
    I have started using Word 2013, as you suggested, and it suffices for the task.
    Thank you for your help.
    Paul Smith

  7. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,846
    Thanks
    0
    Thanked 175 Times in 161 Posts
    Quote Originally Posted by Zmith View Post
    Macros disable the search and find commands. I just wanted a macro whereby I could with one click bring up the first instance of a name I had highlighted in the text using a backwards search from the end of a long document.
    Macros don't disable those commands; indeed you can record macros using them.

    A macro along the lines of what you're asking for is :
    Code:
    Sub FindBibEntry()
    Dim StrFnd As String
    StrFnd = Trim(Selection.Text)
    With ActiveDocument.Range
      With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Text = ""
        .Text = StrFnd
        .Forward = False
        .Wrap = wdFindStop
        .Format = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .Execute
      End With
      With .Duplicate
        .End = ActiveDocument.Range.End
        If InStr(.Text, "Bibliography") > 0 Then
          MsgBox Chr(34) & StrFnd & Chr(34) & " not found in Bibliography.", vbExclamation
        End If
      End With
    End With
    End Sub
    You may also be interested in: http://windowssecrets.com/forums/sho...l=1#post801599
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. The Following User Says Thank You to macropod For This Useful Post:

    Zmith (2014-03-06)

  9. #7
    New Lounger
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Many thanks. Brilliant.

Posting Permissions

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