PDA

View Full Version : Solved: Setting wraptype to Inline with text



mark007
04-27-2005, 02:18 AM
Using Word 2000.

I'm pasting some charts into word from Excel. Some users are on 2003 - in which case I can just call pasteandformat and the result looks good. For 2000 users though things are much uglier as the method doesn't exist.

So in word 2000 I have:

Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False

To paste it in and then:

dim s as ShapeRange
Set s = Selection.ShapeRange
With s
.LockAspectRatio = msoTrue
.Height = 283.45
'.WrapFormat.Type = wdWrapSquare
End With

To format them. The commented out statement is where I have tried all available wordwraps which all seem to do one of 2 things. The text can be typed over it or the text warps round it. The charts do not move with the text though.

What I want is the InLineWithText option something I thought the wdInLine of the paste command might do - but no! I also note that you can't record a macro slecting the inline option.

I've said it before and I'll say it again - I really hate word. MS should completely rip out the object model and start again.... :bug: (though of course leaving the existing one for backwards compataability ;))

Help very much appreciated!

:)



[Edit]

Have now solved by pasting as wdpastemetafilepicture instead of enhanced metafile. Not sure why this works but happy it does!

:)

TonyJollans
04-27-2005, 04:20 AM
Hi Mark,

Perverse things aren't they?

There are Shapes and InlineShapes: I think you have a Shape and want an InlineShape. Try converting it ...

With s
.LockAspectRatio = msoTrue
.Height = 283.45
.ConvertToInlineShape
End With

MOS MASTER
04-27-2005, 11:29 AM
Hi, :D

There's always more than one way of doing this.

I also had this problem once with a sollution who had to work with all version >=97. At the time I wasn't to trilled about the pastespecial methods. All of them did the graph no justice and blurred out the picture..(Some more than others)

At last i did a very relliable approach:
* Use the Export method in Excel to export the chartObject as a *gif file
* Then use AddPicture to insert as InlineShape to make shure it's inline:
Const sPath As String = "C:\Chart.gif"
Sub InsertInline()
Dim oRange As Word.Range
Dim oShape As Word.InlineShape

Set oRange = ActiveDocument.Bookmarks("Picture").Range
Set oShape = ActiveDocument.InlineShapes.AddPicture(sPath, , , oRange)

With oShape
.Height = 100
.Width = 100
End With

Set oRange = Nothing
Set oShape = Nothing
End Sub

This way I get the best quality of pictures in my documents. :whistle: