Solved

MS word Macro insert picture with "behind text" attribute

Posted on 2012-04-04
4
1,139 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

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…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
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.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

831 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