Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-14-2017, 08:17 AM
bronc bronc is offline wrapping text using Word VBA Windows 7 64bit wrapping text using Word VBA Office 2010 64bit
Novice
wrapping text using Word VBA
 
Join Date: Apr 2017
Posts: 5
bronc is on a distinguished road
Default wrapping text using Word VBA

I spend a lot of time cutting an image from Paint into Word and then right clicking to choose Wrap Text and then Tight.



I would like to write some VBA to automate the wrapping (having first selected the "picture").
I recall doing it in 2003 but cant work it out in 2010.
Not sure about the difference between InlineShape and Shape and Picture?
Any help appreciated.
Reply With Quote
  #2  
Old 04-15-2017, 09:50 PM
gmayor's Avatar
gmayor gmayor is offline wrapping text using Word VBA Windows 10 wrapping text using Word VBA Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The default wrap option is in-line thus an in-line shape. To float the image you need to convert it to a shape and then set the wrap of the shape - so assuming that is the case there e.g.:

Code:
Sub Macro1()
'Graham Mayor - http://www.gmayor.com - Last updated - 16/04/2017 
Dim oShape As Shape
    Set oShape = Selection.InlineShapes.Item(1).ConvertToShape
    With oShape.WrapFormat
        .Type = wdWrapTight
        .Side = wdWrapBoth
        .DistanceTop = InchesToPoints(0.1)
        .DistanceBottom = InchesToPoints(0.1)
        .DistanceLeft = InchesToPoints(0.1)
        .DistanceRight = InchesToPoints(0.1)
    End With
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 04-16-2017, 12:09 PM
bronc bronc is offline wrapping text using Word VBA Windows 7 64bit wrapping text using Word VBA Office 2010 64bit
Novice
wrapping text using Word VBA
 
Join Date: Apr 2017
Posts: 5
bronc is on a distinguished road
Default

thats really helpful thanks a lot. just one thing:

there may be more than one inline object beside Item(1) present on the page.

I want to Select the one I want and then run the code to wrap it.
Reply With Quote
  #4  
Old 04-16-2017, 08:46 PM
gmayor's Avatar
gmayor gmayor is offline wrapping text using Word VBA Windows 10 wrapping text using Word VBA Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Have you tried it? Item(1) is the first item in the selection. i.e. the selected image.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 04-18-2017, 05:06 AM
bronc bronc is offline wrapping text using Word VBA Windows 7 64bit wrapping text using Word VBA Office 2010 64bit
Novice
wrapping text using Word VBA
 
Join Date: Apr 2017
Posts: 5
bronc is on a distinguished road
Default

It works a treat
v grateful for your expertise
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
text not wrapping in Word table on Mac only tamarix Word Tables 0 02-26-2017 12:53 PM
wrapping text using Word VBA Word formatting/wrapping text Dracven Word 1 09-19-2016 04:52 AM
wrapping text using Word VBA Word inserting line breaks / wrapping text Girloutside Word 1 08-10-2015 12:45 PM
wrapping text using Word VBA PNG logo in Word- text wrapping and diminishing image quality. sscad27 Word 1 07-08-2014 03:16 AM
word wrapping in a text box (need help asap) 4x4Jeep Word 1 06-21-2012 06:07 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft