Solved

Format Image with VBA

Posted on 2004-09-30
2
2,473 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

732 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