Select All Pictures and Change Wrapping Style to Behind Text

I am trying to get a macro that can change the wrapping style to behind text 
for all the pictures in the document.  It would also be great if I could get 
this macro to change a lot of other properties too.  For example, I want all 
the photos behind text, center horizontal alignment, height = 4", width = 
proportional.  It would also be great if this macro could add a text box 
under each picture which was grouped with its respective picture.  Any advice 
on any of this would be greatly appreciated.
0
Utf
11/19/2009 5:25:02 PM
word.vba.general 1023 articles. 1 followers. Follow

1 Replies
3700 Views

Similar Articles

[PageSpeed] 29

Funny you should ask this now. I was just fighting with the same problem 
yesterday. Using the macro recorder whilst changing the text wrapping from In 
Front of Text to Behind Text and back again yielded an answer. (BTW, Word 
calling it 'text wrapping' is a bit misleading - as you'll soon see. ;-P)

My macro is designed to actually insert an image into a known (bookmarked) 
location within a document, but you should be able to modify it to suit by 
looping through the Shapes collection.

Private Sub InsertProductImage(ProductID As String)
    With ActiveDocument
        If .Bookmarks.Exists("Image") = True Then
        Dim myRange As Range
        Dim myFileName As String
        Dim myPicture As Shape
            myFileName = "P:\Sales Proposal\Images\" & ProductID & ".jpg"
            Set myRange = .Bookmarks("Image").Range
            On Error GoTo NoPic
            Set myPicture = .Shapes.AddPicture(FileName:=myFileName, 
LinkToFile:=False, SaveWithDocument:=True, Anchor:=myRange)
            With myPicture
                .LayoutInCell = True
                .Left = wdShapeCenter
                .LockAnchor = True
                .LockAspectRatio = msoTrue
                .Width = CentimetersToPoints(5)
                .Top = CentimetersToPoints(0)
                With .WrapFormat
                    .AllowOverlap = True
                    .Type = 3
                End With
                .ZOrder 5
            End With
        End If
    End With
Exit Sub

NoPic:
    MsgBox "Unable to find the image for the Product " & ProductID & "." & 
vbLf _
        & "Please contact marketing@canon.co.nz for assistance."
End Sub

The really important bits of this that will most likely be of interest to 
you are found under the 'With myPicture' statement. This is where all of the 
various properties of the image are set, including height, width and, most 
importantly, something called ZOrder. It is this last property that sets the 
text wrapping to Behind Text. (See why I said it's misleading?)

Note that I use the .Left property to set the horizontal alignment 
alignment, but I'm sure there are other ways of doing this. (I can get away 
with this method because the image is inserted into a table cell, which 
controls the alignment well enough for my purposes.) I also just set the 
..Width property and rely on the .LockAspectRatio property to control the 
height; you will probably want to do this the other way 'round.

I don't know about adding the TextBox under the image and grouping it with 
the image, but since you've already got a Range object and a Shape object to 
work with, I can see how it might be done. Check out the .InsertAfter method 
for the Range object. You might have to create a TextBox object first... I'm 
not really sure, and unfortunately, I don't have time to investigate further 
right now. Maybe somebody else has some experience with this and can offer 
some advice?
-- 
Cheers!

Gordon Bentley-Mix
Word MVP

Please post all follow-ups to the newsgroup.

Read the original version of this post in the Office Discussion Groups - no 
membership required!


"ksay85" wrote:

> I am trying to get a macro that can change the wrapping style to behind text 
> for all the pictures in the document.  It would also be great if I could get 
> this macro to change a lot of other properties too.  For example, I want all 
> the photos behind text, center horizontal alignment, height = 4", width = 
> proportional.  It would also be great if this macro could add a text box 
> under each picture which was grouped with its respective picture.  Any advice 
> on any of this would be greatly appreciated.
0
Utf
11/19/2009 8:34:03 PM
Reply:

Similar Artilces:

Hyperlink has changed on file re-opening
[Excel 2002, Win XP Pro] Hi All, i have cells in a sheet whose cell contents are hyperlinked to wor documents. the hyperlink is generated using VBA. part of the fil name includes the '[' and ']' characters (square brackets) when the macro is run, everything works fine (click in one of the cell and the appropriate word file opens) BUT when the workbook is closed an re-opened, the '[' & ']' is changed to '%5b' and '%5d' respectivel (which i guess is some srt of charatcer code for those symbols) if the hyperlink macro is re-run, it 're...

VBA Worksheet Event Change or Selection Question, please assist me
Two fantastic people were kind enough to provide me these two codes below, and now I'm trying to see if I can expand it to include other columns and data in a worksheet. Code 1: Private Sub Worksheet_Change(ByVal Target As Range) Dim myC As Range If Intersect(Target, Range("P:P")) Is Nothing Then Exit Sub Application.EnableEvents =3D False For Each myC In Intersect(Target, Range("P:P")) Range("Q" & myC.Row).Value =3D Date - Target.Value Next myC Application.EnableEvents =3D True End Sub Code 2: Private Sub Worksheet_Change(ByVal Tar...

Format text for "mark my comments with..." #2
Is there a way to format the font & colour of the text I may type into the body of an existing email in Outlook 2003? I have switched the option on so that the comments are flagged with my initials but I wanted them more prevalent by being able to format the colour of the text. At the moment its a manual task. With Word as the editor: Open Word, choose Tools | Options | General tab ... Email Options button ... you can choose the Font in when "Replying or Forwarding messages" -- Bill Rodgers MVP "Greg J" <frog66@flashmail.com> wrote in message news:11246865...

Page break in publisher to change from portraite to landscape
I am trying to change one page from portrate to landscape without effecting the rest of the pages, but each time i try it effects all the pages. I know in word you can select page break. Is there something similar in publisher as i am unable to find this? -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/publisher/200707/1 Pub 2000 here and for me to do what you want I must leave the page in question as portrait and turn the text and images 90�. -- Don Vancouver, USA "chedd via OfficeKB.com" <u18187@uwe> wrote in message news:75f1cac2d1fca@...

Search for a text in a cell and give the outcome later
Dear expert, C30 to C60 contains some data. Say I wan to find piano and use =MATCH("*piano*",C30:C60,0) in cell D31 It gives me the anwer 20 in D31. 20 is the squence of piano. How can I use the function and use return the the whole cell content which is "Play Piano"? I only know where it is. How to locate where and give the whole content in D32 please? Thanks Elton Play games Play golf Play guitar Play piano Play Kite Play Sccoer Play cards Play WII Play music =INDEX(C30:C60,D31) -- Regards! Stefi „Elton Law” ezt írta: &g...

Button or key to conditionally change text foreground color?
I would like to find some quick method (some sort of visible button or hotkey) for the user of a worksheet to change the text foreground color for certain cells in a block of cells (A1:I9) to some specific color if and only if the cell is blank. I.e. when the user hits this "red" key/button, every empty cell in A1:I9 gets a new foreground text color--red. Nothing would be immediately apparent, as these are empty cells, but as soon as the user starts entering values into these cells, the data would be shown in red... a "make all new data red" button/key. Is this possible?...

Changing a cell color....
Hi, Can someone help me how can I change a cell color using the"IF" command??? Thank you, Shaul On Mon, 27 Oct 2003 22:27:56 +0200, Shaul <bagaz@netvision.net.il> wrote= : > Hi, > Can someone help me how can I change a cell color using the"IF" = > command??? Under the Format menu, pick Conditional Formatting. -- = Dave dvt at psu dot edu ...

Can't Change Text direction in office 2007
Hi, i have installed office 2007 ( Pro Plus Edition) on a machine. i have faced a strange thing that i have never seen. the option of changing text direction from right to left or left to right does not exist. it come by default with ltr direction. What's the Problem ? Hi, You need to enable a right-to-left language, such as Hebrew or Arabic. To do this, perform the following steps: 1. Close Word. 2. Click Start, click All Programs, click Microsoft Office, click Microsoft Office Tools, and then click Microsoft Office 2007 Language Settings. 3. In the "Available...

change default settiings for spacing
I am trying to change the default setting for "Don't add space between paragraphs of the same style" by checking this box. It doesn't seem to work however. Is there something I need to do to change this default? Thanks This setting can be made only in style definitions, not in individual paragraphs or selected text or as a default for all styles. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Lucid Moose" <Lucid Moose@discussions.microsoft.com> wrote in message news:55B13F51-D384...

"Play a selected sound" in "create Rule"
I want to use "create rule' "play a selected sound" to notify me of messages from certain people. Screen is on "Create Rule" & "play a selected sound" is not checked. The box beside "play a selected sound" says "chimes.wav" When I check box for "play a selected sound" & do "Browse" to get to 'Control Panel' 'Sounds and Audio Devices', I get the message: 'The file name, or format 'Control Panel" is not valid. Type the file name and location in the correct format, such as...

WINCE desktop icon text
Hello everyone�� How to make the wince desktop icon text background transparent? it is blue and so ugly when i change the Wallpaper��thank you! Auly(from china) I think that, in order to do that, you'd have to rewrite the shell. You have the source, so it should be possible. Look in the right \PUBLIC\SHELL subdirectory for somewhere that the desktop it drawn. Find where the item names are drawn as text and change the code, or allow a registry entry to control whether your change is active or not. I think that, no matter what ...

How can I put a text box in every cell?
Two questions: -How can I put a text box in every cell that I am using WITHOUT having to insert on manually every time? AND - How can I make sure that a text box inserts itself automatically into a new row whenever I add a row? Thanks! One way is to select the row with the text box and copy it to the next row. Copy and paste it several times and then select the rows and paste them as a group. "bmowell" wrote: > Two questions: > > -How can I put a text box in every cell that I am using WITHOUT having to > insert on manually every time? &g...

Changing text based on criteria in an access report
Hello, I've got a textbox in a report, some records of which may contain text within { }. I need to find some way to format only that text (which may be in the middle of a string) so that it appears underlined and so that the brackets disappear. To illustrate, I posted a 5KB graphic here: http://img219.imageshack.us/img219/3523/jexamplemb2.png Does anybody have any suggestions or ideas? Thanks in advance! Mitch Access 2007 can format the text for you, using standard HTML for the underlining. Use the Replace() function to swap the braces for the HTML tags. Earlier versions of Ac...

Using a drop down box to select all results
I have a summary page which pulls data together from several sheets an displays summary statistics etc. I want to be able to use a drop down list to select particular product and only show data relating to those products - so far so good. But ..... having put in my drop down and referenced it in my formulae now cannot show the summary data for ALL products. Is there a wildcard that can be used in drop downs to select all -- Message posted from http://www.ExcelForum.com You could add (All) to your list of products, and check for that selection in the formula. For example: =IF(A2=...

HTML is being converted to text in outlook messages
I have a mixed environment of Exchange 2k3 SP2, and Exchange 5.5 SP4. Currently, the Ex5.5 server is acting as the bridgehead, so all inbound/outbound mail passes through the IMC on that box. My problem is with HTML content within emails. I recieve the messages ok (they are displayed as HTML), but when I forward them, the email loses the HTML content, and displays it in plain text. I have checked the "HTML" box setting in the IMC on the Ex5.5 bridghead server. Is there anywhere else that this needs to be enabled? Any help is appreciated. On Thu, 9 Mar 2006 09:20:31 -080...

Export to Text Files Based on Field Value
I have an Access table with personal information (e.g., first name, last name, birth date, etc.) for thousands of people. The table is sorted by state. I want to be able to run a macro on that table that will create separate pipe delimited text files for each state with all fields included. Any help would be appreciated? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/201005/1 Instead of exporting the table, export a query based on the table. You will have to have some code that loops through the states and modifies the quer...

Changing Chart SourceData in VBA
Excel 97. Can anyone spot where I'm going wrong? I'm trying to change the source data in code so it only shows upto the last cell that has a value in it. My code at the mo is.. Dim intActiveCell As Integer Dim strCell As String Dim strrange As String Sheets("Financial Tracker").Select Range("C13").Select If ActiveCell <> "" Then Do Until ActiveCell.Value = "" ActiveCell.Offset(0, 1).Select Loop End If ActiveCell.Offset(0, -1).Select 'Selection.End(xlLeft).Select strCell = "R" & ActiveCell.Row & "C" &...

Rich Text & Sorting
I have a database that I need alphabetical and I want to color code some of the names. I have sorted the database alpahbetically and saved it with a new name. To sort it, I have to use Text format in my first and last name fields. When I have them listed as Rich Text it will not give me the option to sort when I highlight either of those fields. When I go in and change the name fields to Rich Text so that I can color code them, my database reverts back to not being alphabetical. What am I missing or doing wrong? Being able to color code fields is wonderful, so glad they final...

how to change the Font size and color of a static text control in dialog
New to VC++6.0. I have several static text control in my dialog box as labels. I need to apply different font size and colors to them. How should I achieve that? Tony See the examples given at the following web sites. http://www.codeproject.com/staticctrl/ http://www.codeguru.com/staticctrl/index.shtml -- Cheers Check Abdoul [ VC++ MVP ] ----------------------------------- "Tony Hu" <bytj@yahoo.com> wrote in message news:OL99Bi9SDHA.2280@TK2MSFTNGP12.phx.gbl... > New to VC++6.0. I have several static text control in my dialog box as > labels. ...

is there a way to automatically insert and print random pictures
I am trying to create greeting cards using a variety of different pictures on the cover. Is there a way to automatically insert them from a file so each card has a different picture? You could setup a data base with the pictures, use the catalog merge. Help here Create a catalog merge http://office.microsoft.com/en-us/publisher/HP101921831033.aspx -- Mary Sauer http://msauer.mvps.org/ "judy" <judy@discussions.microsoft.com> wrote in message news:1D33513D-9069-47E9-AB24-E4C88EA8D4C0@microsoft.com... >I am trying to create greeting cards using a variety o...

How do I COMPLETELY change a user name?
Hello, I'm trying to change a user name from JohnSmith to JohnJones. I thought I had changed it properly as it appears as user JohnJones but when they send email, etc...it is still from JohnSmith. What am I forgetting? Thank you in advance, Jack In ADUC. right click on the user object and select "Rename" . That should show up the field that did not get flipped.... "Jack" <Jack@discussions.microsoft.com> wrote in message news:37C7F16C-84C1-4B45-834F-33778CD6A8B4@microsoft.com... > Hello, > > I'm trying to change a user name from JohnSmith ...

Unable to run excel macro after changing file name
After changing the filename in an excel macro, receiving Error number 5 - Invalid procedure call or argument when users with excel 2000 run the macro. Users with excel 2003 are not having this issue Post the line of code that is causing the error. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "merf" <merf@discussions.microsoft.com> wrote in message news:F68DF323-214D-4F01-8D8E-654F9500242E@microsoft.com... > After changing the filename in an excel macro, receiving Error > number 5 - > Invalid procedure cal...

Printing or Not Printing Pictures
Using Access 2007. This may not be the best approach but this is what I have done... I am trying to create a home inspection database. In my table for bathroom I have the following fields referring to pictures: TPic as an Attachment to add pictures of a toilet (don't laugh!); SPic for sink; VHPic for Venting/Heating; BTPic for bath-tub; SHPic for Shower..... On the form for each area (I have the form set-up as pages / tabs) each attachment field is on the applicable page. That works fine. The user can add as many pictures as they want easily. I can put the attachment...

Change the Default Global Address List
Hello, I need to change the default global address list to show only users and contacts from my domain. Is it possible to change the default global address list? Nowadays, The default global address list shows users from my domain and many contacts from others domains. thanks in advance. i have the same situation. i'm trying to figure out how to make another global address list with enternal contacts. if you figure it out, i would love to hear about it:) "Maurit" wrote: > Hello, > > I need to change the default global address list to show only users and >...

Using VBA to find a value and select a range
I am trying to write a macro that will let me find a specific vale in a specific column, then select part of the row that the value is in, beginnign with a column 31 cells away from the column that the specific value is in. Someone suggested to me that I use an IF statement, but this is all I know about that: IF [value in column B] is “Grand Total” Then select from column AF to the end of the array in that row and copy it and paste a transpose of the values starting in cell I9 of worksheet X. What is the best way for me to accomplish this goal? Does this macro do what you...