MS Word Macro - Paste Special

I’d like to run this little challenge by our resident MS Word gurus.

I do an awful lot of copying and pasting of information across platforms, particularly from the web into MS Word. To ensure that the data settles neatly into its new home without the need for constant reformatting, I use the Paste Special command, then choose “unformatted text.” This does exactly what I need it to do, but is in desparate need of streamlining.

I once tried recording a macro wherein I used the paste special command in exactly this way. The problem was that when I ran the macro, it pasted the same text as before, instead of the information I currently had on the clipboard.

So does anyone know how I can amend this? I want to create a macro (which will be assigned a place of prominence on my toolbar) that will insert the *current *contents of the clipboard (not some constant block of text), using the paste special (unformatted text) tool.

Suggestions?

I’ve used Word maybe 10 times in my life, but I’m under the impression that any command can be added into a live menu such as the File menu and/or given a keystroke if it doesn’t already have one.

Before even doing that, I’d try Ctrl-Alt-V and Ctrl-Shift-V (if you’re on a PC) or Command-Option-V and Command-Shift-V (Mac), as those are the most common keystroke commands for “paste without style”.

I just recorded a macro to do exactly as you described, and had no trouble with it. I couldn’t reproduce your problem.

I also had no problems with such a macro.

Try recording the macro again (you’ll probably want to record it to Normal.dot rather than the current document), then go into the Marcos list (Tools|Macro|Macros…), select your new macro and click Edit. You should see something like this:


Sub TheNameYouGaveTheMacro()

' Some stuff here

End Sub

Replace the stuff between the Sub line and the End Sub line so that it looks like this:


Sub TheNameYouGaveTheMacro()

  Selection.PasteAndFormat (wdFormatPlainText)

End Sub

Save, close the Visual Basic editor, and give it a whirl.

Good ol’ Bill Gates and his buggy software

Bottom line: for some versions of Word, the macro recorder records the wrong command. Your macro should look like:


Sub PasteUnformattedText()
    Selection.PasteSpecial datatype:=wdPasteText
End Sub


Just in case anyone’s confused, I’ll just say that my code and K364’s code seem to do the same thing.

But strangely, the Visual Basic help for PasteAndFormat says some weird stuff about ‘pasting the selected table cells’, which has nothing to do with what we’re doing. I have no idea what it’s rambling on about, so it’s probably safer to go with K364’s solution.

Thanks for the input, all. I tried recording the macro again, and it worked properly this time. I can’t for the life of me figure out what I did differently.

This will save me a LOT of time.

I use ALT-E-S-U. It take approximately one second. Writing a macro for that is overkill, IMHO.

Is my proposed solution wrong or problematic? Is it not true that you can assign a specified keystroke to any MS Word menu command? Or am I missing something?

It’s still hard to believe that neither the Option nor the Shift key added to Ctrl-V would already do a “paste without style”, but then again I’m not an MS Word user.

I use PureText. It’s freeware and works across all applications. Windows + V pastes unformatted text. You can choose other hotkey combos also.

The other thing you should do (if you haven’t already) is assign the macro a hotkey. Go to Tools - Customize; click the Keyboard button. Scroll down the list in the left pane to Macros (it’s about 2/3’s of the way down the list); your active macros will appear in the right pane. Click on the PasteSpecial macro. Enter a proposed hotkey under “Press new shortcut key.” You will be advised to what command that key is presently assigned (or told that’s it’s unassigned). If you don’t ever use the hotkey for that command, I say go ahead and overwrite it. Or you can hunt around for an unassigned one. Click “Assign” and the hotkey will be saved in normal.dot (you can specify another template for special purpose macros, but IMHO this one belongs in normal).

I hope that’s clear. If not, let me know.

BTW, AHunter3, I just tried CntlAlt-V in Word 2003 and it’s not assigned to anything. Though, of course, it could be, by the process I just described.

Correction. After I posted, I went to try the suggestion in my last sentence, and find that CntlAlt-V is assigned to InsertAutoText. The hotkey simply didn’t work when I tried it because I was working in a blank document and so, Word had no input to process. So, yes, this hotkey can be assigned to the macro, but you’ll be overwriting something, albeit something I consider eligible for overwriting. In fact, I just did. Adding a second hotkey to a macro I’ve had (and loved) for a long time.

You CAN anssign any command that is a single command with no options directly to a key combo or toolbar button.

The issue with Paste Special is that there isn’t a single command for “Paste Unformatted Text”. There’s a command “Paste Special”, which brings up a dialog box with a variable list of choices for type of paste depending on what’s on the clipboard at that time, any converters you may have installed, etc.

So you can set a keyboard combo that’ll pop up that dialog box. But it can’t also choose the correct selections from the choices available & then [OK] the box.

Hence the need for a one-line macro that takes about 12 seconds to set up, record, and save for posterity. And once it exists, the macro is s single command that can itslef be connected to a keyboard combo or toolbar button.

Oh, OK, that makes sense. I didn’t realize it wasn’t a standalone menu item.

In fact, I have my Paste Unformatted macro assigned to Ctrl+V. I’ve found that I need to paste without formatting far more often than with formatting, and on the offchance that I need to retain formatting, Shift+Insert is still available.