stillmodern.blogg.se

Searching for words in word
Searching for words in word










searching for words in word

in a URL), then the macro won’t highlight it.

  • If some words are missed, check the table containing them - if a word has an initial capital in the table, but not in the document you are searching (e.g.
  • If none of the words in your table get highlighted in your document on the first pass, select a highlight colour from the Home tab as though you were going to highlight manually, then run the macro again.
  • If you get an error message, check that you have the correct file name and path in the macro, AND check that your Word document containing the table that’s called by the macro has no empty rows.
  • Set rReplacement = oTable.Cell(i, 2).RangeĪfter setting up the ReplaceFromTableListName macro (above), run it on a test document - copy an existing document and test on the copy to make sure you don’t mess up anything.

    searching for words in word

    Options.DefaultHighlightColorIndex = wdTurquoise wdYellow, wdBrightGreen, wdPink, wdTurquoise ' Make sure highlight is set to the colour you want, e.g. Set oChanges = Documents.Open(FileName:=sFname, Visible:=False) SFname = "C:\Users\rhonda\AppData\Roaming\Microsoft\Word\STARTUP\find_and_replace_routines_names_macro.docx" 'Change the path in the line below to reflect the name and path of the table document ' from Doug Robbins, Word MVP, Microsoft forums, Feb 2015, based on another macro written by Graham Mayor, Aug 2010ĭim oChanges As Document, oDoc As Documentĭim rFindText As Range, rReplacement As Range

    searching for words in word

    NOTE: Copy all the code below to the clipboard - it goes off the page, so don’t type it out as you’ll miss some of it or could make a typo. You need to change it to YOUR file name and YOUR file path. Once you’ve added it, change the line that starts with sFname and has the file path - that path points to MY file on MY computer. Step 2: Set up the macro to work with the tableĪdd the macro below to an existing document, or better, an existing template, or even better, a central macros template that loads whenever you open Word. Save the document to this folder, noting the name of the file as you’ll need that later:Ĭ:\Users\\AppData\Roaming\Microsoft\Word\STARTUP.(This means that the wildcard find/replace will replace what was found with itself - remember, you’re only trying to identify the words that *may* need changing at this point, not changing them.) In the left column, type in the words/phrases you want to find, each on a different row.Start a new Word document, and create a two-column table in it.I figured that using a variation of the ReplaceTableWithList macro (as discussed here: ) and a new table called by that macro variation should solve it. SolutionĪlthough there may be several ways you can do this, I decided to stick with what I already knew. One project’s documents were to be the basis of a set of documents for another project in the same company, so one of the tasks was to ‘personalize’ the copies of the original project’s documents with the names used by the new project. The words related to project names, company names, facility names, document number prefixes, etc. She didn’t want to change them at this stage. As there were MANY documents she had to process, she needed an easy way to find these words and highlight them. The scenario for this one is a little different - the author wanted to find various words in a document and highlight them for probable change. This post assumes you can already do what’s in that earlier post. I suggest you read that post first (and test it) before attempting this one. This is a variation on the multiple find/replace macro covered here.












    Searching for words in word