Macros and VBA
This page last revised: 13 Dec 2017 05:24:01 -0600 .
Let's use the macro to update all the fields in the document as an example.
Sub UpdateAll()Dim oStory As Range Dim oField As Field On Error Resume NextFor Each oStory In ActiveDocument.StoryRangesFor Each oField In oStory.FieldsoField.Update
On Error GoTo 0
5. Copy the complete block of code from the newsgroup post to the clipboard.
6. Switch to the macro editor window.
7. Click the 'save' icon and close the editor.
8. From Word's document screen, right click on the toolbar and select 'customize' then from the command list (left window) select macros.
9. In the macro list (right window) pick your newly created macro with the left mouse button and drag it to your toolbar and drop it where you would like it to appear. (Or drop it in an appropriate menu if you prefer). Right click on either entry and edit the name to something sensible - for a toolbar button use an abbreviation or suitable icon. You can change the display to "default" from "text only" as well.
10. Close the 'customize' wizard and the macro will be available to your documents. If you saved it in normal.dot or another global template, it will be available to all of your documents. If you saved it in a template, it will be available in all documents based on that template (so long as the template is still "attached." See Template Basics for more on the various kinds of templates and how to use them.
><<> <>>< ><<> <>><
(With suggestions from Ibby and editing by CK.)
Graham has put this on his own web page which is probably more up-to-date.
If this isn't making sense, you may want to read it put another way on the MVP website in the article by Dave Rado.
If you are careful, you can use your own macros to intercept and replace standard word commands (that are triggered by buttons already on a built-in toolbar). See Intercepting Events like Save and Print by Dave Rado, Anna-Karin Bohman and Jonathan West.
The up-to-date version of this FAQ may be found at:
Download this FAQ in Word 97 format
Changes / suggestions / ideas can be sent to Charles Kenyon.
views since 13 April 2004
Many people visit this site and use the information it
Copyright 2000-2017 Charles Kyle Kenyon
FAQ provided as an adjunct / hobby as a part of my web site as a
criminal defense lawyer.