[**This article is about 1,300 words total. Those who want to fit it into 1,000 words can eliminate some of the Tips and Tricks at the end. One figure (WordAFig14.pcx) is referenced in the article. **]
Importing Text from Microsoft Word into AutoCAD R14
by Mark Middlebrook
copyright © 1997 by Daedalus Consulting
AutoCAD R13 and R14 added many improvements for text creation and editing, but it still can be a chore to create large blocks of text, such as a sheet of general notes or a table of abbreviations. Ideally, you'd like to create and edit the text in a word processor such as Microsoft Word and then import the document into AutoCAD.
Pasting the word processing document via OLE (object linking and embedding) is one possibility in R14 (see chapter 16 of the R14 AutoCAD User's Guide for instructions), but this approach has several limitations and problems:
- It's difficult to control. You can't directly specify text height, so sizing the word processing document in AutoCAD is a process of trial and error.
- You can't link or embed a document longer than one page.
- OLE objects sometimes don't plot correctly, depending on the plotter driver you're using and the nature of the OLE objects themselves.
This article describes an alternative method for creating text in a word processor and transferring the text into AutoCAD while maintaining simple formatting such as hanging indents. The goal is to ensure that What You See in your word processor is What You Get in AutoCAD.
The instructions here are for Microsoft Word 7.0, but you can modify them for other word processors, such as WordPerfect. This method relies on using a fixed width font (a font in which every character takes up the same amount of horizontal space) in both Word and AutoCAD, because that's the only straightforward way to maintain a hanging indent (see figure). If you don't need hanging indents, you can use proportionally spaced fonts such as RomanS.Shx.
In Microsoft Word
Start by setting up a new document and creating the notes in Word.
- Use the Style dialog to change the fonts of the Normal style and any other styles you intend to use to Courier New (Format, Style, Modify, Format, Font). The example in the figure uses 12 point Courier New in order to make the text more legible and reduce the number of characters per line.
- For numbered items with numbers to the left of the text, as shown in the figure, create a style with a hanging indent and list numbering turned on. To automatically add a line space between numbered items, set Space Before to a size that's at least as large as the point size for the style. The example in the figure uses Word's default List Number style with Hanging Indent changed to 0.5", Space Before set to 12 points, and a single tab stop set at 0.5" (Format, Style, Modify, Format, Paragraph, Spacing Before and Tabs). For best results, the hanging indent should match the tab spacing.
- Type in the notes. You can use Word formatting that affects the spatial layout of text (e.g., tabs). You also can check spelling and hyphenate the document.
- When you've finished entering the text, save the document in Word's native DOC format, and then save it again as an MS-DOS text file with layout preserved. To save in this format, use Save As on the File menu and choose "MS-DOS Text with Layout" in the "Save as type" drop-down list. (If you don't see "MS-DOS Text with Layout" as a choice, you need to install the converter from your Word CD see Tips and Tricks below for details.) When you save to this format, Word wants to add an ASC extension to the file name. To override this extension, type the file name in quotation marks: "GenNotes.Txt".
In AutoCAD
- Create or open the drawing in which you want to put the notes.
- Use LAYER to create or set current the layer on which you want to put the notes.
- Use STYLE or STYLE to create a style with a fixed width font. The only fixed width SHX font that comes with AutoCAD is MonoTxt, which is pretty ugly. Try a custom font like MonoSimp.Shx instead (see Tips and Tricks below).
- Use the Edit MText dialog's (i.e., MTEXT command's) Import button or the R12 AscText.Lsp program to import the ASCII text file that you exported from Word. The figure shows the results with MTEXT.
- Use DDEDIT and other AutoCAD commands to do any fine tuning, such as changing the height or font of titles.
Tips and Tricks
- Be aware that you now have three copies of the notes: one in Word DOC format, one in ASCII text format, and one in your AutoCAD drawing. Make sure that you establish a revision control system. One method is to always make changes to the Word file, and then go through the export-to-ASCII then import-to-AutoCAD process again. You may want to delete the ASCII text file right away, to prevent someone from accidentally editing that copy, instead of the Word original.
- You don't have to use a fixed width font, but if you don't, then the letter spacing will be different in Word than in AutoCAD. In particular, you won't be able to create hanging indents properly.
- The custom font MonoSimp.Shx, developed by Gale Gorman, is a fixed width version of Simplex/RomanS. It is available free in MonoSimp.Zip from library 3 of the ACAD forum on CompuServe. There are numerous other fixed-space fonts available from third-party vendors. Ask your dealer or check the ads in CADALYST and CADENCE magazines.
- If you use a custom font like MonoSimp.Shx, you need to send it along with the DWG file to anyone else who uses your drawing (consultants, service bureaus, etc.). You're allowed to send a freeware font like MonoSimp.Shx, but most third party vendors expressly prohibit you from providing copies of their commercial font files to others. Some vendors offer special licensing arrangements.
- Another fixed width option in R14 is TrueType (TTF) fonts. For example, you can use the Courier New font that comes with Windows or one of the Monospace 821 fonts that come with R14. Be aware, though, that drawing and plotting performance is much slower with TTF fonts than with AutoCAD's native SHX fonts.
- The Edit MText dialog's Import button allows you to import an ASCII text file easily as paragraph text. Another option is the AscText.Lsp program, which comes with R12 (in the \Acad\Support directory). AscText.Lsp imports the text file as individual line text objects, and it lets you set up columns of text.
- In general, you should stick with simple formatting and ordinary alphanumeric characters. Fancy effects like underlining, bold-facing, and special symbols won't survive the trip from Word to ASCII to AutoCAD. You can type in the old AutoCAD special character codes (%%C, %%D, and %%P), but if you use MTEXT, you'll need to edit the text object once in order to force conversion to Unicode format (just run DDEDIT, select the text object, and choose OK). You can use %%U for underlining if you import the text with ASCTEXT, but MTEXT doesn't recognize %%U.
- If you don't see "MS-DOS Text with Layout" in the "Save as type" drop-down list, then you need to install the text converter from the Word CD or disks. In the Microsoft Office setup program, choose Microsoft Word, the Change Option button, Text Converters, the Change Option button again, and click the check box next to Text with Layout Converter.
- Once you create a set of Word styles and other settings that work well for documents that you export to AutoCAD, you can save those settings to a Word document template (DOT) file. Then the next time you start a new document, use File, New and select the document template. Word document templates are similar to AutoCAD template drawings.
- Word's text file formatting is not always perfect. You may have to do minor editing to the ASCII text before importing it into AutoCAD.