The issue of InlineShapes and Shapes in Word is odd, at best. There are a number of properties that are NOT exposed by the object model; there are a number of properties that are not shared bewteen InlineShape and Shape. BehindText is one.
In the thread listed above some of these are mentioned. To get an InlineShape (which is usually what it is) to go behind text, it must be converted to Shape. Then you can use ZOrder - as is posted in the thread.
Further, quite a number of properties are not available to the macro recorder, and can only be found by deep search within the Object Browser, and real study of the object model itself.
So to answer, there is no simple syntax. It is very very strange in there - the way Word handles graphics. Walk with care. Play with it on a file that you can afford to screw up first.
Driving InlineShapes is truly weird!
If you want real fun then try resizing a mixture of portrait and landscape pictures in your document with VBA...
I wanted to be able to resize inserted photos by scaling them by a fixed factor. No matter what I tried there was no consistency with the results; some were OK, some were squished.
Dim myheight As Integer
Dim mywidth As Integer
Dim myscale As Integer
Dim ans As Integer
myheight = Selection.InlineShapes(1).Height
mywidth = Selection.InlineShapes(1).Width
myscale = Selection.InlineShapes(1).ScaleHeight
MsgBox "Height is " & myheight & " width is " & mywidth & " Scale is " & myscale
Selection.InlineShapes(1).Fill.Visible = msoFalse
Selection.InlineShapes(1).Fill.Solid
Selection.InlineShapes(1).Fill.Transparency = 0#
Selection.InlineShapes(1).Line.Weight = 0.75
Selection.InlineShapes(1).Line.Transparency = 0#
Selection.InlineShapes(1).Line.Visible = msoFalse
Selection.InlineShapes(1).LockAspectRatio = msoTrue
Selection.InlineShapes(1).ScaleHeight = 'try a scale factor
Selection.InlineShapes(1).ScaleWidth = 'try a scale
Selection.InlineShapes(1).PictureFormat.ColorType = msoPictureAutomatic
End Sub
I totally agree. Word is VERY weird when it comes to graphics InlineShapes, and Shapes. If you really really look at the object model, it does start to make sense from a strange Twilight Zone sort of direction.
Frankly, I have moved away from InlineShapes / Shapes as much as possible. I still have to, when dealing with other people's documents. For my own, more and more I am using ActiveX controls. They have direct events that are useful; and they can be scaled easily. There are some oddities there as well.
For example the ActiveX Image control scales the control to the size of the loaded image. On the the other hand, the Label control scales the image to the size of the control - which is MUCH more likely to be the intent.
ALL ActiveX control in a Word document can contain images. While they do not have a .Visible property, they do have well behaved .Height and .Width properties which can shrink the control down to sub-pixel dimensions...which is REALLY weird. This takes serious testing as the viable dimensions are taken directly from the printer driver. As do all screen elements in Word.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.