Solved

Format Image with VBA

Posted on 2004-09-30
2
2,457 Views
Last Modified: 2008-01-09
What is the proper syntax to format an image as "Behind Text" with VBA.

For Example, I have this code:

Selection.InlineShapes.AddPicture FileName:=FileName.Jpg

Now how can I format that image so that the image is behind text (equivilant to Format | Picture | Layout | Behind Text).

Thanks
0
Comment
Question by:DRJ
2 Comments
 
LVL 15

Accepted Solution

by:
Colosseo earned 500 total points
ID: 12197751
HI DRJ

The only way i can think is to convert the inlineshape to a shape and then set the zorder.

Building on your code...

' Add image
Set inlineimg = Selection.InlineShapes.AddPicture(FileName:=FileName.Jpg)

' Convert to shape
Set tmpImg = inlineimg.ConvertToShape

' Move behind text
tmpImg.ZOrder msoSendBehindText

' Tidy up
Set tmpImg = Nothing
Set inlineimg = Nothing

HTH

Scott
0
 
LVL 8

Expert Comment

by:Jupiler78
ID: 12197757
Hi DRJ,

Try this

Dim Pict1 as inlineshape
    set Pict1 = Selection.InlineShapes.AddPicture FileName:=FileName.Jpg
    Pict1.Select
    Selection.ShapeRange.ZOrder = 1

The ZOrder defines the order of the object, 1 is last a new one is given 2 and is on top of 1

Cheers!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now