Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-24-2018, 04:45 AM
Bluebell Bluebell is offline Wrap text code not working Windows 8 Wrap text code not working Office 2010 64bit
Novice
Wrap text code not working
 
Join Date: Jan 2014
Posts: 10
Bluebell is on a distinguished road
Default Wrap text code not working


I have writing a manual and need to insert a lot of screen prints. I have go the following code to fix the aspect ratio and add the required border which works fine.
I find that although my setting are for Top and Bottom alignment this does not always work when I drag the images in so wanted to add a line of code to change the image type to Top and Bottom alignment

I am using Word 2016 running Windows 10. My code is as follows but I get Compile error: Method or data member not found when I add the wrap format line. Can someone please point out what I am doing wrong please
Many thanks


HTML Code:
Sub AllShapes()
' Sets all selected shapes to Locked Aspect Ratio
Dim oSh As Shape
Dim oSl As InlineShape
 
   For Each oSh In ActiveDocument.Shapes
            oSh.LockAspectRatio = True
            
   Next
   For Each oSl In ActiveDocument.InlineShapes
            oSl.LockAspectRatio = True
            oSl.Line.Weight = 2
            oSl.Line.Style = msoLineSingle
            oSl.Line.ForeColor.RGB = RGB(91, 155, 213)
            
            oSl.WrapFormat.Type = wdWrapTopBottom 'Compile error with this line of code            
           
   Next

 
End Sub
Reply With Quote
  #2  
Old 03-24-2018, 11:24 PM
Guessed's Avatar
Guessed Guessed is offline Wrap text code not working Windows 10 Wrap text code not working Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You can't wrap text around an inline shape. So you need to convert it to a shape first
Code:
Sub AllShapes()
  ' Sets all selected shapes to Locked Aspect Ratio
  Dim oSh As Shape, oSl As InlineShape
 
   For Each oSh In ActiveDocument.Shapes
      oSh.LockAspectRatio = True
   Next
   For Each oSl In ActiveDocument.InlineShapes
      oSl.LockAspectRatio = True
      oSl.Line.Weight = 2
      oSl.Line.Style = msoLineSingle
      oSl.Line.ForeColor.RGB = RGB(91, 155, 213)
      Set oSh = oSl.ConvertToShape
      oSh.WrapFormat.Type = wdWrapTopBottom
   Next
End Sub
Note that converting the inlineshape to a shape might result in the loop going to every second inline shape. If that is the case, you will need to step backwards through the inline shapes.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 03-25-2018, 02:46 AM
Bluebell Bluebell is offline Wrap text code not working Windows 8 Wrap text code not working Office 2010 64bit
Novice
Wrap text code not working
 
Join Date: Jan 2014
Posts: 10
Bluebell is on a distinguished road
Default Wrap text code not working

Thank you for this, I will see if it is worth my while - not too hard to click on the position button if it comes in incorrectly.
Thank you
Reply With Quote
  #4  
Old 03-25-2018, 03:44 AM
Bluebell Bluebell is offline Wrap text code not working Windows 8 Wrap text code not working Office 2010 64bit
Novice
Wrap text code not working
 
Join Date: Jan 2014
Posts: 10
Bluebell is on a distinguished road
Default Word Wrap still not working

I now have a macro which I think converts to a shape, but when I then try and align the shape it still does not recognise the "shapes". I get an unqualified error. Any clues gratefully received. Also how do I know whether a shape is a shape or an inline shape? or an inline shape just that selection on the wrap text button?
HTML Code:
Sub AllShapes()
'add a blue thin border and locks aspect ratio
Dim oSh As Shape
Dim oSl As InlineShape
 
  
   For Each oSl In ActiveDocument.InlineShapes
            oSl.LockAspectRatio = True
            oSl.Line.Weight = 2
            oSl.Line.Style = msoLineSingle
            oSl.Line.ForeColor.RGB = RGB(91, 155, 213)
         
      Next
      
 Call ConvertToShape
 Call TopBottomAlign
 
End Sub

Sub ConvertToShape()
Dim i As Integer, oShp As InlineShape

For i = ActiveDocument.InlineShapes.Count To 1 Step -1
    Set oShp = ActiveDocument.InlineShapes(i)
    oShp.Select

    With Selection
    
                If oShp.Type = wdSelectionInlineShape Then
            .InlineShapes(1).ConvertToShape
            
        End If
    
    End With
    Next i
End Sub

Sub TopBottomAlign()
Dim shp As Shape
For Each shp In ActiveDocument.Shapes
           .WrapFormat.Type = wdWrapTopBottom ' unqualified error occurs here
        Next
End Sub
Reply With Quote
  #5  
Old 03-25-2018, 04:15 AM
Bluebell Bluebell is offline Wrap text code not working Windows 8 Wrap text code not working Office 2010 64bit
Novice
Wrap text code not working
 
Join Date: Jan 2014
Posts: 10
Bluebell is on a distinguished road
Default So sorry

I am sorry but I did not see your solution in the window - am trying that now
Reply With Quote
  #6  
Old 03-25-2018, 04:26 AM
Bluebell Bluebell is offline Wrap text code not working Windows 8 Wrap text code not working Office 2010 64bit
Novice
Wrap text code not working
 
Join Date: Jan 2014
Posts: 10
Bluebell is on a distinguished road
Default All working

Thank you very much, this is my final code which covers both shapes and inline shapes
You are a star

HTML Code:
Sub AllShapes()
'add a blue thin border and locks aspect ratio
'if the image is already a shape uses this macro

Dim oSh As Shape
Dim Osl As InlineShape
For Each oSh In ActiveDocument.Shapes
            oSh.LockAspectRatio = True
            oSh.Line.Weight = 2
            oSh.Line.Style = msoLineSingle
            oSh.Line.ForeColor.RGB = RGB(91, 155, 213)
            oSh.WrapFormat.Type = wdWrapTopBottom
            Next
'formats the shapes and if an inline shapes converts to shapes and aligns top and bottom
 For Each Osl In ActiveDocument.InlineShapes
            Osl.LockAspectRatio = True
            Osl.Line.Weight = 2
            Osl.Line.Style = msoLineSingle
           Osl.Line.ForeColor.RGB = RGB(91, 155, 213)
          Set oSh = Osl.ConvertToShape
      oSh.WrapFormat.Type = wdWrapTopBottom

      Next
      
 
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrap text code not working Wrap text in text box around image with transparent background pstidsen Word 4 02-08-2016 03:30 PM
Wrap text code not working How to Wrap Text on Images in Text Boxes mrniceguy Word 1 02-16-2014 04:42 PM
Wrap text code not working Text wrap chuckmg@acm.org Word 6 10-01-2013 07:39 PM
Wrap text code not working Wrap Text function not working? mhays Excel 1 11-21-2012 05:03 PM
Text Won't Wrap WRowan Publisher 0 06-14-2012 09:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:29 PM.


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