Macro to Allow Inserting Drawings Inline Rather than ...



Macro to Allow Inserting Drawings Inline Rather than Floating in MS Word

The following Macro named EditPasteObject was taken from Microsoft Knowledge Base Article ID: Q163808 at

The purpose is to allow drawing objects created in Word to be inserted inline rather than floating, which is normally the only option in Word. The reason for wanting to do this is that often, inline objects behave more predictably than floating objects. Once inserted, you can use Format / Picture to choose whether the picture floats or not.

To use, (0) Install the Macro in the desired document(s) as described below in Installing and Running the Macro. (1) Draw the picture as normal in Word. (I recommend drawing it on a separate blank document). (2) Group the entire picture. (3) Copy the picture to the clipboard. (4) Paste the picture as an inline object into the desired document by running this macro (see Installing and Running the Macro instructions below). If you want to paste the object normally (as a floating object), just use the Paste command on the Edit menu.

Sub EditPasteObject()

On Error GoTo ErrHandler ' Error will occur if object is Office Art.

ActiveWindow.View.Type = wdPageView

Selection.PasteSpecial Placement:=wdInLine

' If the object is not text, then convert it.

If Selection.Type = wdSelectionShape Then

Selection.ShapeRange.ConvertToInlineShape

End If

ErrHandler:

If Err 0 Then

' If the object is Office Art, paste it as an inline picture

ActiveDocument.Undo

Selection.PasteSpecial DataType:=wdPasteMetafilePicture, Placement:=wdInLine

End If

End Sub

Here is an originally drawn picture, which is floating:

Here it is converted to inline using this macro:

[pic]

Installing and running the Macro:

Note: Steps (1) – (6) install the macro, and need only be performed once per installation of Word if it is installed to normal.dot. Steps (7) – (10) are used each time you want to paste a drawing inline.

(1) Select the Macro code (in the shaded region above in this document) and copy it to the clipboard.

(2) Select Tools / Macro / Macros (Alt + F8).

(3) (a) In the Macro name: box type EditPasteObject

(b) In the Macros in: box select normal.dot (global template) to automatically include this macro in all documents when opened. Otherwise, choose This Document to only install it in the current document.

(c) In the Description: box you can type anything you want .

(d) Select the Create button. The Visual Basic editor window opens.

(4) In the code window, replace the skeleton code for EditPasteObject with the actual code you have copied to the clipboard in step (1). Do not delete or change the code for AddOurToolbar or anything else that appears.

(5) Select File / Save (Ctrl+S) to save the macro and your updated document.

(6) Select File / Close and Return to Microsoft Word (Alt + Q)

Now the macro is installed. In order to run it,

(7) Open the document containing your (floating) drawing, make sure it is fully grouped, select it, and copy it to the clipboard using Ctrl+C or Edit / Copy.

(8) If you are pasting it into a different document, open the destination document.

(9) Select Tools / Macro / Macros (Alt + F8). If EditPasteObject does not appear in the list box, then select normal.dot in the Macros in: box.

(10) In the list box, select EditPasteObject and click run. Your drawing should appear in the destination document as an inline picture object.

If you later decide to modify the picture, convert it back to floating using Format / Picture. Ungroup it if necessary, make the changes, then repeat steps (7) – (10).

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download