Solved

MS word Macro insert picture with "behind text" attribute

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
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…
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 …

856 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