Converting Text Boxes to Text

I've recently needed to help several people convert Microsoft Word text boxes to text. Is there something in the wind? Whatever is going on, if you're having to copy and paste, copy and paste, to get that text out where you can use it, you'll appreciate the following macro, which pulls text-box text out as regular text and styles it with a character style named "OnceABox," colored red for easy identification. To (eventually) get rid of the red, just delete the character style. (Thanks to Geoff Hart, David Chinell, and Janna DeVore for inspiration.)

If you don't know how to use such macros, you'll find instructions here:

http://lists.topica.com/lists/editorium/read/message.html?mid=1706922855

If you have lots of documents that need to be converted, you might consider running the macro with my MultiMacro program:

http://www.editorium.com/14844.htm

And now, the macro. Enjoy!

'THE MACRO STARTS HERE
Sub ExtractTextBoxes()
Dim NoStyle As Boolean
Dim aStyle As Style
Dim aShape As Shape
Dim i As Integer
'Check for "OnceABox" character style
NoStyle = True
For Each aStyle In ActiveDocument.Styles
If aStyle.NameLocal = "OnceABox" Then
NoStyle = False
Exit For
End If
Next aStyle
'If necessary, create "OnceABox"
'character style
If NoStyle Then
ActiveDocument.Styles.Add Name:="OnceABox", _
Type:=wdStyleTypeCharacter
With ActiveDocument.Styles("OnceABox").Font
.Color = wdColorRed
End With
End If
'Style textboxes and convert to frames
For Each aShape In ActiveDocument.Shapes
If aShape.Type = msoTextBox Then
i = i + 1
aShape.Select
aShape.ConvertToFrame
Selection.Style = _
ActiveDocument.Styles("OnceABox")
End If
Next
'Clean and delete frames
For i = ActiveDocument.Frames.Count _
To 1 Step -1
With ActiveDocument.Frames(i)
.Borders.Enable = False
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = _
wdColorAutomatic
.BackgroundPatternColor = _
wdColorAutomatic
End With
.Delete
End With
Next
End Sub
'THE MACRO ENDS HERE

_________________________________________

READERS WRITE

Following up on my February 9 article on Microsoft's seeming inconsistency regarding tracked changes, Ed Nelson sent this interesting comment:

We must accept the changes, but reject the inserts to get equivalent results, the omission of the text under consideration.

Sometimes the problems we see come from outside circumstances conflicting with the way our mind sees the issue in the first place. Here's what I'm trying to get at:

We may see the issue as being "What is this command going to do to the text before me?" And what the commands do *does* seem opposite to each other. But if we see it as "What will this command do to the established procedure?" the resuilt isn't so weird. To overcome the Insert process, the new text gets omitted. To overcome the prior editorial correction, the new text (a different item in this case) also gets omitted.

Contradictory procedures are both being overcome. Consistent, No?

------------------------

In the March 24 newsletter, Ed Millis asked for help with the final checking of a document, including, as he wrote, "ensur[ing] all tables and figures are numbered correctly and correspond to their text mention, mak[ing] sure every paragraph has the proper indent and reference (every (a) has a (b), and it's not (b) when it should be (2), and I didn't overlook any abbreviations."

The generous and brilliant Eric Fletcher responded:

I run into similar types of issues as described by your reader Ed Millis, but would never consider printing the document! IMHO, viewing it on the screen is not only less wasteful of paper, but with a few tweaks, you can focus specifically on the particular issue.

I would use Find & Replace's wild card feature to highlight all elements contained within parentheses, then put the file in normal view (zoomed up quite large so I could lean back and do my review with mouse only . . . ), use the Find dialog to find the first instance of a highlight, then use the downward pointing icon in the lower left of the vertical scrollbar to skip through and review all of the others.

For abbreviations, you can pull everything in all caps to a second document, then sort it and look for anomalies. Use Find with wildcards to look for the pattern "[A-Z]{2,5}" (to get all instances of 2-5 capital letters) but choose "Find All" instead of the normal Find. This will select all instances. Drop out of the dialog and Ctrl-C to copy. Make a new document and Paste: you will have a complete set of all found items. When sorted, abbreviations that don't look right are easy to spot.

In fact, for this application, I typically set the abbreviations in their own character style so I can pull them for generating an acronym list. Some abbreviations don't follow the all caps rule ("SoS/E" is a recent example in a book I'm working on for example), but if I have a button to attach the style, it is easy to do as I encounter it. Then, later, I can pull anything tagged with the "abbreviation" style to help create the acronym list.

I have a little macro that helps me correct all other instances of a selection and set them in a character style. I needed it to set Latin names in a document where they needed to be ignored for spell check, but were inconsistently spelled and presented in the supplied content. For example, "tuberosa" was sometimes "tuberaso" but both needed to be tagged as my "Latin" style. As I review words that had been set in italics (Find, Ctrl-i), and came across a word I had not yet set, I can select it and click my SetLatin button. The VBA code presents "tuberaso" (selected) in a dialog and lets me type in "tuberosa". When I click Okay, it uses the VBA Replace all to fix any other instances throughout the document. What makes this particularly helpful is that I have the "Latin" character style set in a temporary colour (say purple) so that as I progress through the document, terms I've dealt with show up distinctly because they are coloured. I then reset the colour to automatic within the style definition before I complete the job. Here's the code I use (it can be modified to fit other requirements):

[Editor's note: I've broken lines so they'll work when copied from this email newsletter. Also, before using the macro, you must create a character style named "Latin." You should take seriously Eric's suggestion to modify the macro to fit other requirements; this macro could be a very useful tool for many purposes.]

'THE MACRO STARTS HERE
Sub SetLatin()
' Proposes to replace the selected string
' with whatever you type in,
' and applies the Latin character style
' to each instance.
'
' Set up to deal with correcting
' all instances of italicized words
' in a scanned document (e.g., Latin names)
' because they can be both misinterpreted
' and need to be set in italics consistently.
Dim strReplacement As String
strReplacement = _
InputBox("Replace all instances of [" & _
Selection.Text & _
"] with whatever is entered below, " & _
"and also set each with the " & _
"Latin character style.", _
"Set all like this as Latin", _
Selection.Text)
If strReplacement <> "" Then
With ActiveDocument.Range.Find
.Text = Selection.Text
.MatchWholeWord = True
.Replacement.Text = strReplacement
.Replacement.Style = _
ActiveDocument.Styles("Latin")
.Execute Replace:=wdReplaceAll, _
Forward:=True, Wrap:=wdFindContinue
End With
End If
End Sub
'THE MACRO ENDS HERE

The advantage of using code like this is that it doesn't change what you have set in the Find & Replace dialog. If I did it within the dialog, I'd need to remember to turn off the style the next time I used the dialog. I have several little chunks of code for such things, and it can really improve the efficiency of reviewing.

Incidentally, my temporary colour method can also be very handy for setting styles. If the main body styles area all defined to be based on, say, Body Text, I can set its colour to green. Then, as I tag the content by whatever method, the paragraphs with my styles attached will show up in green so I can concentrate on the non-green content. This is particularly useful if you use either Find & Replace to help tag, or use the "Select all instances" option available from the Styles and Formatting task pane. Either way enables you to assign styles "blindly," but with the colour, you can see what remains to be tagged manually as you review.

This is probably only peripherally relevant to Ed's question, but hopefully some of it will apply!

------------------------

Many thanks to Ed and Eric.

_________________________________________

RESOURCES

Are you writing for the web, or editing text to be published on the web? You'll find the Web Style Guide to be an invaluable aid:

http://www.webstyleguide.com/

This entry was posted in Editing. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

You must be logged in to post a comment.

  • The Fine Print

    Thanks for reading Editorium Update (ISSN 1534-1283), published by:

    The EDITORIUM, LLC
    http://www.editorium.com

    Articles © on date of publication by the Editorium. All rights reserved. Editorium Update and Editorium are trademarks of the Editorium.

    You may forward copies of Editorium Update to others (but not charge for it) and print or store it for your personal use. Any other broadcast, publication, retransmission, copying, or storage, without written permission from the Editorium, is strictly prohibited. If you’re interested in reprinting one of our articles, please send an email message to editor@editorium.com

    Editorium Update is provided for informational purposes only and without a warranty of any kind, either express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. The user (you) assumes the entire risk as to the accuracy and use of this document.

    The Editorium is not affiliated with Microsoft Corporation or any other entity.

    We do not sell, rent, or give our subscriber list to anyone. Period.

    If you’d like to subscribe, please enter your name and email address below. We publish the newsletter once a week, and on rare occasions we may send an important announcement. We never, ever send spam. Thank you for signing up!