Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Silicon Valley, California, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pasting Metafile In Text Layer (Word 2000)

    Hi Folks,

    I have a lot of Excel charts I want to represent in a Word document without having them linked. The procedure I follow produces satisfactory results, but it is tedious:
    1) Copy in Excel, switch to Word, choose Paste Special, select Enhanced Metafile.
    2) Open the Format Picture dialog, change Layout to Inline With Text, Size (width) to 4.5" (I want 4 graphs per landscape page, which I accomplish with two paragraphs, each with two graphs in line with the text).
    3) Drag the picture to the location within the text I want.

    I tried recording a macro, but "Inline With Text" is grayed out when recording. I modified the code and ended up with this:

    <pre> With Selection
    .PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _
    Placement:=wdInLine, DisplayAsIcon:=False
    .ShapeRange.Width = 324
    .ShapeRange.ConvertToInlineShape

    End With
    </pre>


    It works, but I always still have to follow step 3) (drag the picture to the location I want). I tried changing the code to do the following:
    a) Add a bookmark at the current cursor location.
    [img]/forums/images/smilies/cool.gif[/img] Paste Special and Convert, as in the code above.
    c) Move the resulting picture to the bookmark.

    I am stumped how to do step c) because 1) after the ConvertToInlineShape method, the picture is no longer selected, and 2) I don't know how to reference it for a Cut and Paste or a Move of some sort.

    This seems a lot more tedious than it should be. Any advice is appreciated.

    JIM

  2. #2
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Silicon Valley, California, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pasting Metafile In Text Layer (Word 2000)

    Hi again,

    Never mind, here is what I came up with. The key turned out to be, assigning the result of ConvertToInlineShape to an object variable, then doing further operations on the object variable:

    <pre> ActiveDocument.Bookmarks.Add Name:="PutItHere"
    Dim s As InlineShape

    With Selection
    .PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _
    Placement:=wdInLine, DisplayAsIcon:=False
    .ShapeRange.Width = 324
    Set s = .ShapeRange.ConvertToInlineShape
    s.Select
    .Cut
    ActiveDocument.Bookmarks("PutItHere").Select
    .Paste
    ActiveDocument.Bookmarks("PutItHere").Delete

    End With

    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •