Logo: TechTrax...brought to you by MouseTrax Computing Solutions

Paste Special Unformatted Text At Your Fingertips

by Herb Tyson, MVP and author of Word 2007 Bible

I watched over Harry's shoulder as he copied text from the web page into the clipboard, then Alt/Tab(ed) (Good boy!) over to Word. Then, I watched in horror as he clicked the Paste tool on the toolbar, and a massive blob of formatted text slowly appeared in the middle of his neatly formatted Word document.

Harry then selected the text he'd pasted and proceeded to strip the formatting out. (Ctrl/Spacebar will do this nicely, by the way.) I cleared my throat. He plodded ahead, now that he could read the pasted insertion. I cleared my throat again, more meaningfully this time, and he asked "Okay. What did I do this time?"

"Well" I began, "It's more what you didn't do."

"Huh?" he asked.

"Back up," I told him. "Press Ctrl/Z to undo and remove what you just did."

Obligingly, he pressed Ctrl/Z several times as the blob of formatted text reappeared then disappeared. "Now, what?" he asked.

"Click on Edit, then Paste Special, then on Unformatted text. Now press Enter." I commanded.

Image of the Paste Special Dialog box showing the Unformatted Text item selected.

Harry's body shook as his multi-step process was reduced to a single menu command. Scanning the toolbars he asked "Is there a tool or a keyboard shortcut that does that?"

"Not yet," I replied, knowing this would pique his interest further.

Not Yet, and Not Quite
Using Word's built-in tools, you could save yourself a little bit of work by assigning Edit/Paste Special to a keystroke or a tool. Choose Tools/Customize/Keyboard. Under Categories:, choose Edit. Under Commands:, scroll down to the entries that begin with EditPaste (tap the E key to get to the E items more quickly). In addition to EditPaste, there are usually six other EditPaste options, including EditPasteSpecial.

Click on EditPasteSpecial. Notice that Current Keys is empty. Click in the Press new shortcut key: box, and tap an unused key combination. Since Ctrl+V is Paste, let's use Alt+Shift+V. Now click Assign/Close/Close to exit the various dialog boxes.

Now wander off elsewhere in windows and copy some formatted text to the clipboard. Arriving back in Word, press your new shortcut key. Depending on what you copied, you might have several options starting with the letter U. Tap the U key until Unformatted text is selected, then press Enter.

Well, that's a bit easier than what Harry did. But, it's not quite as convenient as it could be. That's because, in their less-than-infinite wisdom, Microsoft's design team didn't include EditPasteUnformatted in their ready-to-wear rack of commands. Instead, you'll need to D.I.Y. (do it yourself).

Recording the Macro
Sometimes, in Word, you can record a macro, and it works perfectly. Other times, Word gets way too specialized and thinks you're interested in the text itself rather than in the process. Let's see what Word does in this case. First, copy some formatted text to the clipboard.

Now, choose Tools/Macro/Record New Macro. In Macro name:, type EditPasteUnformatted. Ensure that Store macro in: is set to All Documents (Normal.dot), then click Keyboard. We might as well save some time while we're here. Let's use Alt+Shift+V as before. Click Assign and then Close.

Now, the Stop Recording toolbar appears. Usually, you won't be able to read the full text in its title bar. In your Word window, do what I showed Harry, earlier. Choose Edit/Paste Special/Unformatted text, and click OK. Why not press Enter? When recording macros, you don't want to take a chance that pressing Enter does something you don't want done. So, take deliberate steps, and go directly to the buttons you want.

Back in the document, hover the mouse over the Stop Recording toolbar tools, leftmost tool. Verify that the tooltip says Stop Recording, and click it (or use the Tools/Macro/Stop Recording menu commands).

With luck, that's all you need to do. Let's see. Press the key combination you assigned to the macro (Alt/Shift/V). Darn! The formatting came along for the ride. No luck. So, we'll have to do some surgery. That will give us an opportunity to move the macro to its own module while we're at it.

Editing the Macro to Make It Do What You Want
In Word, choose Tools/Macro/Macros (the shortcut for this is Alt/F8). Select EditPasteUnformatted and then click on Edit. This opens the Microsoft Visual Basic Editor (VBE). On the left, you should see Project/Normal (the Project Explorer) and Properties/NewMacros (the Properties Window) window-ettes. At the right, you see the guts of the macro you recorded.

Image of the VB editor, showing the code that's just been recorded.

The macro you see is not what you want to see. Replace the line:

	Selection.PasteAndFormat (wdPasteDefault)

With:

	Selection.PasteSpecial Link:=False, DataType:=wdPasteText

Before moving on, let's test it to see if it works now. Leaving the VBE open, switch back to the Word window and try the assigned keystroke again. It should now insert the contents of the clipboard just as if you'd used the menu to insert Edit/Paste Special/Unformatted text.

A Module of Its Own
You could just leave the macro where it is. Lots of Word users do. Personally, I like to tuck macros into new modules. That makes it easier (later on) to see what they are in various menus and submenus. Let's move the macro to a new module. Back in the VBE, click in the window where your macro text is and press Ctrl/A to select the whole macro, then Ctrl/C to copy it to the clipboard.

At the left, in the Project Explorer, right click on Modules and choose Insert/Module. That creates a module named Module1 (unless it's not your first). In the right window, paste the contents of your clipboard. The macro appears. Now, let's name the module something more useful. You could create a special module for this and future paste-related macros. Or, you could just give each macro its own dedicated module name. Let's do the former.

In the Properties Window, use the mouse or keyboard to select the name Module1. Delete it, and replace it with the name Paste, pressing Enter to seal the deal. Above, Module1 is now replaced by the new module name.

At the moment, your recorded macro still exists, and the key combination is assigned to it. In the Project Explorer, double-click on the NewMacros module. In the macro window, select everything from Sub EditPasteUnformatted to End Sub, and press the Delete key. Click the X in the upper right corner of the VBE window to close the editor.

The only things left now are to reassign the keystroke to the "new" version of the macro, test to make sure it works, then make sure that the results are saved in Normal.dot.

Back in the Word window, choose Tools/Customize/Keyboard. Set Categories: to Macros, and set Macros: to EditPasteUnformatted. In Press new shortcut key:, press the key combination you want to use. If you reuse Alt+Shift+V, Word says it's [unassigned]. That's because the assignment took a hike when you deleted the NewMacros version of the macro. Click Assign/Close/Close.

Image showing the keyboard customization dialog with the newly modified macro selected for assignment.

Back in your document, make sure you have some formatted text stored in the clipboard, and press the newly-minted keyboard shortcut. Cool!

Of Menus and Toolbars
If you're more of a toolbar person, you'll be happy to know that you can easily assign your creation to a toolbar. Choose Tools/Customize/Commands tab. Set Categories to Macros, and set Macros to Normal.Paste.EditPasteUnformatted. Drag the macro to a toolbar and drop it where you want it.

Ugly, right? With the Customize dialog box still onscreen, right click the monstrosity and choose Default Style. Now, you have an icon. Still ugly, but smaller. Right click the icon and choose Change Button Image. Choose one of the 36 pre-fab icons shown (for now). Then choose Close. Test the button by clicking it.

You could also assign the macro to a menu or a popup menu. Rather than covering every conceivable topic in this article, however, we'll leave the intricacies of that to you, and we'll delve into the complexities of which-popup-menu-is-which later on. But, for now, as they say, that is left as an exercise for the student.

 

 

Go up to the top of this page.
This site powered by the Logical Web Publisher™: Content management by Logical Expressions, Inc.