Word Macro to Paste Unformatted Text.

There are many times when I wish to copy the text only from a particular web page, to a Word document. To do this, I normally navigate to the respective web page, to select the whole page, to copy the text to the clipboard, navigate to the Word document and select Edit >> Paste Special >> Unformatted Text. This pastes the text without the images and tables. Since this can be quite monotonas when copying text from various web pages to Word documents, a Word macro can be created and add to the toolbar. The steps to create this macro:

  1. Start Word.
  2. Navigate to the Tools menu >> Macro >> Record New Macro…
  3. This opens the Record Macro dialog box, where you can name the macro and then click OK. I choose PasteText as the name for my macro.
  4. Now that the macro has started recording, carry out the steps of copying the text from the web page to the word doc i.e. navigate to the respective web page, , , navigate to the Word document and select Edit >> Paste Special >> Unformatted Text.
  5. Stop recording.

    If you test your newly created macro, you will see that it still pastes the full web page i.e. text with images and formatting. The reason for this can be seen in the macro’s code which is as follows:

    Sub UnformattedText()

    ‘ UnformattedText Macro
    ‘ Macro recorded 3/5/2006 by Paulode

    Selection.PasteAndFormat (wdPasteDefault)
    End Sub

    For some reason, Macro Recorder added the type ‘wdPasteDefault’, the normal copy and paste with text and images, instead of ‘wdFormatPlainText’, to paste unformatted text. After making the respective change, the code should look as follows:

    Sub UnformattedText()

    ‘ UnformattedText Macro
    ‘ Macro recorded 3/5/2006 by Paulode

    Selection.PasteAndFormat (wdFormatPlainText’)
    End Sub

To add the macro to the toolbar, carry out the following steps:

  1. Navigate to the Tools menu >> Customize >> within the commands tab, scroll down the categories list to select Macros.
  2. Click the Macros Categories and this will list your macro in the Command window.
  3. Click and drag your macro in the Commands windows to the toolbar.
  4. Although it defaults to placing it as a string of text, you change that by right-clicking and selected a different option from the pop-up menu.

Advertisements

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: