Wednesday, July 23, 2008

Macro Madness - Copying without Formatting in Word

Microsoft are an institution of this age. How could it survive otherwise with such buggy products? People use Office because most other people use Office, and it is harder to "collaborate" from some other suite of products. Office is not too large to fail - nothing is - but without some Bear Stearns loss of liquidity, it is not going to disappear overnight. Instead, there is the slow decline in market share to competitors such as Google and OpenOffice, and the loss of revenue to piracy. It can't come soon enough for me - as long as the upstarts have learnt from MS's mistakes.

The biggest problem of all is featuritis - packing new features into the product so that customers upgrade to new version. Because Microsoft did (and still does not, for all that I know) ask what the customers want, the customers get a lot of unwanted additions. Remember the dancing Paperclip? Of course you do. Then there's the automatic formatting, and the one hundred and one permutations of AutoCorrect.

Because of Microsoft's top-down approach to its base, they also miss the obvious. For example, paste without formatting. It's obvious - people want to cut some text from somewhere but without the formatting crud. The source may use bullets or numbers or odd fonts or different colours. The destination uses the standard Word styles. All the fancy styling is undesired. But by using the standard Paste function, that's what the destination gets.

Microsoft does let the customer do this, but they don't make it easy. Rather than provide a nice one-click menu item or a shortcut key, the user has to choose Edit → Paste Special from the menu, and then choose the "Unformatted Unicode Text" option. It's ok if you do it once or twice. Unfortunately, my job involves updating old software requirements documents, and that includes updating the content to a new style. Doing these actions 100+ times a day was becoming a strain.

So I wrote these macros, and then gave them shortcut keys for quicker use. (I chose Alt+U and Alt+C, but others can make their own.) Add them to your Normal.Dot or whereever else you want.

The PasteUnicode is the simplest - it just pastes without formatting. The CopyUnicode is a stranger beast. One of the snafus of Word is how it copies bullets and numbering - it "thinks" the user wants the number in the numbering or the bullet in the bulleting. When copying from sources, I found it was better to make the text "plain", copy, and then undo the operation. That's what the macro does. It's a kludge, and I'm not happy with it, but at least the macro alerts you if there are problems. Use with care - preferably when the source is read-only.

Sub PasteUnicode()
'
' PasteUnicode Macro
' Macro written 8/03/2008 by DaOOSG
' Free for distribution.
Selection.PasteAndFormat (wdFormatPlainText)
End Sub

Sub CopyUnicode()
'
' CopyUnicode Macro
' Macro written 18/07/2008 by DaOOSG
' Free for distribution.
Selection.Style = ActiveDocument.Styles("Normal")
Selection.Copy
If ActiveDocument.Undo = False Then
MsgBox ("Undo was unsuccessful")
End If
End Sub

Any feedback is appreciated. Cheers.