Solved

MS word Macro insert picture with "behind text" attribute

Posted on 2012-04-04
4
1,064 Views
Last Modified: 2016-10-29
Here is what I have for the macro, I want the image to be behind the text.  What am I missing?
Thanks,
John

Sub test()
'
' test Macro
'
'
    Dim shp As Shape
    Set shp = ActiveDocument.Shapes.AddPicture( _
        FileName:="C:\jkf.bmp", _
        SaveWithDocument:=True, _
        Anchor:=ActiveDocument.Paragraphs(1).Range, _
        Left:=InchesToPoints(3), _
        Top:=InchesToPoints(5.5), _
        Width:=InchesToPoints(2.5), _
        Height:=InchesToPoints(0.9))
End Sub
0
Comment
Question by:John_Fretz
  • 2
4 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 37809842
You need to change the WrapFormat Type:
Sub test()
'
' test Macro
'
'
    Dim shp As Shape
    Set shp = ActiveDocument.Shapes.AddPicture( _
        FileName:="C:\jkf.bmp", _
        SaveWithDocument:=True, _
        Anchor:=ActiveDocument.Paragraphs(1).Range, _
        Left:=InchesToPoints(3), _
        Top:=InchesToPoints(5.5), _
        Width:=InchesToPoints(2.5), _
        Height:=InchesToPoints(0.9))
    With shp.WrapFormat
        .Type = wdWrapBehind
    End With
End Sub

Open in new window

0
 

Author Closing Comment

by:John_Fretz
ID: 37810822
Thanks for the help.<br />Cheers,<br />John
0
 

Expert Comment

by:Jorge GONZALEZ
ID: 41864571
May I have your help? where is the error?

Sub Firma_JoGo()
'
' Firma_JoGo Macro
' Esta Macro inserta la Firma


'a) create new shape as object variable
Dim SHP 'As InlineShape/As Shape
Set SHP = Selection.InlineShapes.AddPicture(FileName:="C:\Users\Jorge Gonzalez\OneDrive\Imágenes\Firma JoGo.jpg", LinkToFile:=False, SaveWithDocument:=True)
'b) changes made according to SHP variable:
With SHP
    'this will convert to shape 'in front of text' then 'Behind the Text'
    .ConvertToShape
    WrapFormat.Type = wdWrapBehind

 
End With


End Sub
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 41864953
Jorge GONZALEZ
Please open a new question. That way all experts who monitor the MS Word zone will be notified. Only contriburos to this question (two people) will be notified of your comment.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
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…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

929 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

13 Experts available now in Live!

Get 1:1 Help Now