Solved

Format Image with VBA

Posted on 2004-09-30
2
2,467 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Word / Printing 8 65
help with flyer 3 81
Word files to Wordpress Posts 2 65
is it possible to scan a document directly into Microsoft Word 2013? 14 74
When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

828 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