[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Format Image with VBA

Posted on 2004-09-30
2
Medium Priority
?
2,486 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 2000 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Suggested Courses
Course of the Month18 days, 16 hours left to enroll

834 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