Example: Copy the text string from a MText object to a Microsoft Word document (AutoLISP/ActiveX)

The following example creates an AutoLISP application that works with Microsoft Word 2010 and an AutoCAD drawing that contains MText.

Note: ActiveX support in AutoLISP is limited to Windows only.

Create a new AutoLISP program and load the ActiveX support functions

  1. In Visual LISP, click File New File.
  2. Click File Save As.
  3. In the Save As dialog box,
    • Specify a location for the new AutoLISP source file.
    • In the File Name box, enter copyMText2Word.
    • In the Save As Type drop-down list, select Lisp Source Files.
    • Click Save.
  4. In the new Visual LISP text editor window, enter (vl-load-com).

Obtain the AutoCAD application and current ModelSpace objects and store their pointers

Import the Microsoft Word type library

Change the :tlb-filename argument in the following code to point to the msword8.olb file on your system.

Establish a connection to a Microsoft Word application

Process the MText objects in model space

Load and run the code

  1. In Visual LISP, click Tools Load Text in Editor.
  2. At the AutoCAD Command prompt, enter copymtext2word and press Enter.