sponsored by:

rpsoft 2000

- software -

  Tips and Hints
for using

Ms Word
 
     
 

 

 
     
 

Ms Word Macros

Macros are commands that can do multiple actions at one simple button click.  They therefore can be extremely powerful.  They do take some practice, however, in setting up.  The examples below are based on some very simple concepts, but end up helping to create some very powerful macros.

Creating Editing and Storing Macros

There are several ways to create macros - including recording.  However this section will only deal with the simplest means of all - directly writing them.  If that seems a lot of work, it is not.  We will just use the "Edit" function of the macro under "tools" in the pull down menu, and then use the computer clipboard to transfer text directly into the program area.  For modifying the macro commands?  One can use the computer clipboard transfer method to create new lines.  Do the simple changes on each line by hand.  We will explain this in the following examples.

Let us take an example in Ms Word that we used in the previous page for Find and Replace.  Let us say that we wish to eliminate the ">" character from a text file.  A macro code to do this is as follows:

Sub bracket()
WordBasic.EditSelectAll
WordBasic.Style "Normal"
WordBasic.Font "Arial"
WordBasic.FontSize 11
WordBasic.StartOfDocument
WordBasic.EditReplace Find:=">", Replace:="", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
End Sub

Explanation of the macro:

  • note that this macro subroutine begins with line one saying "Sub" and ends with a line that says "End Sub". These items are required

  • the name of this subroutine was chosen to be "bracket" which is shown in line 1.  We could have picked almost any name.  Keep the name to one word though (no spaces)

  • Select All on the second line means that all of the text will be selected for change

  • The next 3 lines are optional, but are used to change all of the text to Normal Arial style, with font size of 11.  Change those items to suit your own tastes.

  • "StartOfDocument" tells the software to begin the search at the start of the documeent

  • The next line is the text for Find and Replace - the real work horse in this macro and others we will show.  This particular macro has only one Find and Replace preceded by only one StartOfDocument - but as we will see later, there can be many of these lines to further manipulate text

  • The second to the last line places the cursor again at the start of the document

  • Note that the Find and Replace routine here searches for "Find" = ">" and will "Replace" it with "" - which is the symbols for replacing it with nothing (zero length).

Saving and Using this Macro

note:   these instructions are specifically for Ms Word 2000; you might have to look around your version of Ms Word if it is a different version to achieve similar results.

We will use the computer clipboard to transfer this text to a macro.  We learned how to do this on the last page.  If you do not remember how to do this, please look at "Clipboard Memory" on the previous page.  But basically, what we will do is to highlight the text for the macro as you see it in your browser for just the subroutine.  Use your mouse instead of "Ctrl" and "A" since you want only the subroutine text and not the whole browser page.  Then open Ms Word.  Open "Tools" on the pull down menu, and under "Macros" move your mouse to the right and select "Macros" again.  A macro window should pop up, showing you macros that you currently have loaded in Ms Word.  You may already have a macro there, or not have any.  Select "Edit" and a screen will show a large open macro area to the right hand side.  Set your mouse cursor at a point in an open area on the right hand side where you can load this macro text and yet not interfere with another macro loaded there.  How to do that?  Not that macros begin with the word "Sub" and then the macro title and end with "End Sub".  Ensure that if you have other macros there that you place it before another "Sub" or after "End Sub" but not within another macro.

After you have done this, your macro is loaded.  Ensure that you select "Save Normal" under the pull down file under "File" before leaving.  This will save your macro work to the disk.  Then you can exit the macro screen by pressing the "X" in the upper right hand corner of the macro window.

Using the Macro

You can use the macro by first loading the text file into Ms Word that you wish to modify in order to remove the ">" symbol.  Then you can go to "Tools" in the pull down menu, and again select"Macros" bringing up the macro window.  Then select the macro you wish to exercise, which would be name "bracket" in this case, and select "Run".  Then the macro should modify your text and remove the ">" symbols.

Macros on Tool Bars for Simple Usage

A more elegant way of dealing with macros that you use often is to put them on the Ms Word toolbar.  Under "tools" and then "customize" you can create a new toolbar just for your macros by selecting the "toolbar" tab and selecting the "New" option.  The name is not important of this new toolbar, and calling it "custom 1" as they suggest is just fine.  Then you can add your new "bracket" macro to this toolbar.  You can do that with this "customize" window by selecting the "commands" tab, and then looking down "categories" for "macro" and then selecting the "macro" category.  The macros available will show on the right.  Drag the name of the bracket macro from this window to the top new custom toolbar that you just created.  Since the name of it will likely be too long, before closing the custom window, right click on the bracket name in the new tool bar with your mouse (must be a right click) and modify the "name" that is shown.  Then delete characters or give it a shorter name such as "bracket" or even "brk" or similar such that it will take up less space on the toolbar. 

Now in the future, when you wish this macro to execute and modify a document, you need only press "bracket" on the toolbar with your mouse to execute the macro.

Modifying your Macro

You might notice that you really need "> " with a blank after the ">" to be replaced rather than just the ">" itself.  Well, to do that go under "Tools" and "Macros" again to open the macro window.  Select the "bracket" macro and then the "Edit" function.  Change the Find and Replace routine such that "Find" is now "> ".  Then select "Save Normal" again under "File" in the menu to save your work, and then exit the macro screen.  When the macro is executed, it will now have this change.

More Powerful Macros

The below is a much more powerful macro that I use to straighten out margins on emails that appear messed up when they arrive. Of course one must also copy it to Ms Word to use this macro.  Note that this macro is an approximation and may work on simple emails, but not complex ones such as those with bullet items on each line.  This simple macro is expecting normal paragraphs and then a double line break between paragraphs.  It also uses a special temporary character "$$**" that it uses to tell where these double line breaks should go.

Note that even with its higher complexity, that it simply uses the Find and Replace routine several times as its work horse to get the job done.  A lot of complexity can be done with just the power of Find and Replace.  Note also that as indicated on the last page, that the symbol "^p" means a line break.

How does one create added Find and Replace lines, each with "StartOfDocument" before it?  Use the computer clipboard to copy a set of those two lines, and then paste them as many times as you need.  You will only need then to modify the "Find" and "Replace" data for the copied lines to the new desired targets.

Sub paragraph()
WordBasic.EditSelectAll
WordBasic.Style "Normal"
WordBasic.Font "Arial"
WordBasic.FontSize 11
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="^p^p^p^p^p^p", Replace:="$$**", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="^p^p^p^p^p", Replace:="$$**", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="^p^p^p^p", Replace:="$$**", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="^p^p^p", Replace:="$$**", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="^p^p", Replace:="$$**", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="^p", Replace:=" ", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="$$**", Replace:="^p^p", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="     ", Replace:=" ", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="    ", Replace:=" ", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="   ", Replace:=" ", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:="  ", Replace:=" ", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
WordBasic.StartOfDocument
WordBasic.EditReplace Find:=" ", Replace:=" ", Direction:=0, MatchCase:=0, WholeWord:=0, PatternMatch:=0, SoundsLike:=0, ReplaceAll:=1, Format:=0, Wrap:=2
End Sub

 

NEXT PAGE - Excel and More

 

 

 
     
     
     
 

To rpsoft 2000 software

 
     
   
RPSOFT 2000 SITEMAP

RPSOFT 2000 PRODUCT

HOME PAGES

INFORMATION (click here for guide)

utility products

blackjack products

home page

ms office

music theory

blackjack

music chords

blackjack game

About Us

web sites

midi music

best bets

site crawler

contact manager

support

digital photos

pool tips

ship sizes

email address bk.

file name changer

CD Sales

corel tips

sl-animations

audio noise

memory bank

metric conversion

eBooks

HDTV terms

MVP Baseball

madden game