17
VBA Find and Replace Download program from the following Web site: http://gregmaxey.mvps.org/word_tip_pages/ vba_find_and_replace.html The purpose of this Microsoft Word Help & Microsoft Word Tips page is to provide "VBA Find and Replace©," a Word template add-in for Word2003\2007\2010, to the Word user community. VBA Find and Replace© provides a method for finding and replacing text anywhere in a document (or collection of documents) using single user defined "find" and "replace" variable pairs, or a user defined list of "find" and "replace" pairs. It also provides a method to find text and replace found text with a user defined "AutoText" or "Building Block" entry. The add-in has been around for a while and over the years I have made several "quick" changes and modifications to support suggestions from its many users and fans. It had become rather complex and a bit unwieldy as a result and so with this release I decided to give it a face lit and completely overhaul the code. The goal of course was to make the add-in easier to use. I think I have done that, but you the user are the final judge. There are two versions of the add-in. Numbered the same, the versions are nearly identical with the exception of the user controls used to initiate the add-in. The .dot version works in Word2003\2007\2010. The .dotm version is intended for Word2007\2010 users. The user interface (UI) controls and their locations are shown below. Note: Prior to this update I have not used version numbering with this add-in. To avoid confusing

VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

VBA Find and ReplaceDownload program from the following Web site:http://gregmaxey.mvps.org/word_tip_pages/vba_find_and_replace.html

The purpose of this Microsoft Word Help & Microsoft Word Tips page is to provide "VBA Find and Replace©," a Word template add-in for Word2003\2007\2010, to the Word user community.VBA Find and Replace© provides a method for finding and replacing text anywhere in a document (or collection of documents) using single user defined "find" and "replace" variable pairs, or a user defined list of "find" and "replace" pairs. It also provides a method to find text and replace found text with a user defined "AutoText" or "Building Block" entry.The add-in has been around for a while and over the years I have made several "quick" changes and modifications to support suggestions from its many users and fans. It had become rather complex and a bit unwieldy as a result and so with this release I decided to give it a face lit and completely overhaul the code. The goal of course was to make the add-in easier to use. I think I have done that, but you the user are the final judge.There are two versions of the add-in. Numbered the same, the versions are nearly identical with the exception of the user controls used to initiate the add-in. The .dot version works in Word2003\2007\2010. The .dotm version is intended for Word2007\2010 users. The user interface (UI) controls and their locations are shown below.

Note: Prior to this update I have not used version numbering with this add-in. To avoid confusing current users I have started version numbering beginning with 2.0.

Page 2: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

.dot version adds a Word 2003 Menu Command

.dot and .dotm version adds a Word 2007/2010 Ribbon Add-Ins tab control

Page 3: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

.dotm versios add a Word 2007/2010 Ribbon Home tab>Editing group control

Executing either of the UI controls displays the add-in user interface. As you should see from the illustration, features are disabled until qualified. For example, you can't "EXECUTE" or define a "Find what/Replace with" variable pair until a "Search using" option is selected.

Page 4: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page
Page 5: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

Note: Since this add-in was initially intended for performing multiple find and replace operations using a defined list, "Find whole words only" is true by default.Selecting "a single word/phrase" as the search option qualifies and enables appropriate controls for user input. Notice that you still can't "EXECUTE" because you have not defined a valid "Find what" variable.

Page 6: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page
Page 7: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

Defining a "Find what" term qualifies the remaining controls thus allowing the user to execute the operation.

Page 8: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page
Page 9: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

Note: Just like with the built-in replace utility, leaving the "Replace with" field empty deletes (replaces with nothing) any found text when the process is executed. Perhaps you will find it annoying, but I have added a confirmation requirement is this case.

Page 10: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page
Page 11: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

When the "a single word/phrase" option is selected and with a "Find what" field entry defined, the "AutoText Entry (as replacement) option becomes available. This powerful feature lets you select a defined AutoText\Building Block entry to use as the "Replace with" variable.

Page 12: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page
Page 13: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

After executing "SELECT AUTOTEXT," the user selects and inserts a predefined AutoText\Building Block entry from the displayed dialog. This process automatically copies the selected AutoText\Building Block entry to the system clipboard and the add-in uses the clipboard content as the "Replace with" variable

Note: The "AutotText Entry (as replacement) option is available only with the "a single word/phrase" search option.

Page 14: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page
Page 15: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

The remaining "Search using" options use one of three user defined lists containing "Find" and "Replace" pairs to perform repetitive replace operations on a single document of collection of documents in a selected batch folder. As sample "QuickList" is shown below.

The add-in provides feedback to the user as operation are executed/completed.

Page 16: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page
Page 17: VBA Find and Replace - Accessing Higher Groundaccessinghigherground.org/handouts2013/HTCTU Alt Format... · Web viewThe purpose of this Microsoft Word Help & Microsoft Word Tips page

An execution log is available when the "Process Files in Batch Folder" option is used.

The "Info/Tips" command button provides information and tips for using the add-in.Download the templates here: VBA Find and Replace.

For more on template add-ins and how to load them, see the heading: Organizing Your Macros/Template Add-ins at: Installing MacrosThat's it! I hope you have found this tips page useful and informative.

http://gregmaxey.mvps.org/word_tip_pages/vba_find_and_replace.html