Macro to remove text with specific style in MS Word 2003

A writer who is required to format a MS Word document might find this piece of code very useful. This has helped me a lot in the past and I would like to share it with others as well. The exact procedure to use the code is mentioned below. In simple words what it does is that, if you have text in a Word document with specific style applied to it that would like removed, this code would do that for you in a matter of seconds. This tool is only for subscribers, and you can download the template with the code from the member’s area.

Summary

This macro is editable and can be modified based on user requirements. The macro searches for text in the document that has (”Heading 1”) style applied to it. It then selects the text and deletes it; this procedure is looped such that the text with (”Heading 1”) style no longer exists. If you would like text with another style removed, you can modify the code accordingly with the style name and run the piece of code as usual.

Note: To keep track of all the changes made to the document while the macro runs, Turn ON Track Changes.

Information

1.       Start or switch to Word

2.       On the Tools menu, point to Macro, and then click Visual Basic Editor.

3.       On the Insert menu, click Module.

4.       In the module, copy and paste the following code:

<CODE IS AVAILABLE IN THE FREE GOODIES SECTION.>

5.       On the File menu, click Close and Return to Microsoft Word.

6.       On the Tools menu, point to Macro, and then click Macros.

7.       In the list of macros, select the DeleteHeading1 macro. Click Run.

Note: To turn on Track Changes Go to Tools -> Click Track Changes (or) Hold Ctrl+Shift+E

If you want to use with more than one document, you can add a button to one of the document toolbars to run the macro. To add a button for a macro to a toolbar, follow these steps:

Procedure

1.       Open the document that contains the macro. If you have just added a macro to your current document, save your document. For this procedure to work, your file must be saved before you create the button.

2.       On the Tools menu, click Customize.

3.       Click the Commands tab.

4.       Click Macros in the Categories list.

5.       Drag the name of your macro from the Commands list and drop it on one of your toolbars. This adds a button to the toolbar to run the macro.

6.       Click Close.

Macro to delete text with specific style – click to download

I’m yet to test this piece of code on Word 2007 and once I’m done with it I will have it uploaded to the members area as well.

Advertisements

Tags: , , , ,

One Response to “Macro to remove text with specific style in MS Word 2003”

  1. KonstantinMiller Says:

    Hello, can you please post some more information on this topic? I would like to read more.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: