Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2018, 08:38 PM
brent chadwick brent chadwick is offline Macro to format picture Windows 8 Macro to format picture Office 2013
Advanced Beginner
Macro to format picture
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default Macro to format picture

Hey guys, a friend asked me about a macro to do some picture formatting on a Mac but I have no idea where to start with this one. This is what she would like the macro to do after selecting an image:


1. Format Picture menu
2. Wrap Text – Top and Bottom
3. Border – Dark Gray
4. Shadow – outer


Any suggestions?

Reply With Quote
  #2  
Old 09-20-2018, 11:00 PM
macropod's Avatar
macropod macropod is offline Macro to format picture Windows 7 64bit Macro to format picture Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your description is a bit vague. Try the following for a starting point:
Code:
Sub Macro1()
With Selection
  If .InlineShapes.Count <> 1 Then Exit Sub
  With .InlineShapes(1)
    With .Borders
      .Enable = True
      .OutsideLineWidth = wdLineWidth300pt
      .OutsideLineStyle = wdLineStyleSingle
      .OutsideColorIndex = wdGray50
    End With
    .Shadow.Visible = True
    .Shadow.Style = msoShadowStyleOuterShadow
    .Shadow.Size = .Height
    .ConvertToShape
  End With
  .ShapeRange(1).WrapFormat.Type = wdWrapTopBottom
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-11-2018, 09:24 AM
brent chadwick brent chadwick is offline Macro to format picture Windows 8 Macro to format picture Office 2013
Advanced Beginner
Macro to format picture
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

Yes Paul, she was a little vague. When I run this code I get an error on the line
[.OutsideLineWidth = wdLineWidth300pt]


I've changed the line width with no success. Suggestions?
Reply With Quote
  #4  
Old 10-11-2018, 02:26 PM
macropod's Avatar
macropod macropod is offline Macro to format picture Windows 7 64bit Macro to format picture Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try swapping the order of:
.OutsideLineWidth = wdLineWidth300pt
.OutsideLineStyle = wdLineStyleSingle
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-12-2018, 05:30 AM
aysherryan aysherryan is offline Macro to format picture Windows 7 64bit Macro to format picture Office 2010 64bit
Novice
 
Join Date: Aug 2018
Location: Singapore
Posts: 5
aysherryan is on a distinguished road
Default Try the following

Dim shp As word.Shape
'' Works on the currently selected Shape
Set shp = Selection.ShapeRange(1)
'' If you know which Shape, by index or by Name, then
' Set shp = ActiveDocument.Shapes(indexOrName)
'' If the object is currently an InlineShape it must first
'' be converted to a Shape
' Set shp = InlineShapeObject.ConvertToShape
shp.WrapFormat.Type = wdWrapFront
Reply With Quote
  #6  
Old 10-12-2018, 01:46 PM
macropod's Avatar
macropod macropod is offline Macro to format picture Windows 7 64bit Macro to format picture Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The error message reported by the OP has nothing to do with your supposition that the image is a wrapped shape; indeed, the desire to apply top/bottom wrapping implies it is not.
Quote:
Originally Posted by aysherryan View Post
' If the object is currently an InlineShape it must first
'' be converted to a Shape
That simply isn't true; the borders & shadowing - which your code doesn't even attempt - can be applied beforehand. Moreover, your own code for the wrap format conversion follows your attempt to process the selection as a shape (it must precede that!!).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to format picture how to exit from Format 'Picture Tools'? ftcnet Word 1 07-28-2016 12:21 AM
Macro to format picture what picture format best for first pdf then printing ketanco Word 1 04-11-2016 05:46 PM
Macro to select an { includepicture } field code and format the picture behind text and 100% scale sanpedro Word VBA 3 03-30-2015 10:50 PM
Macro to format picture "format picture" - arrows show as no line atop picture marbeth Word 3 07-08-2011 02:16 PM
Problem w/ Format Picture (size) John Woram PowerPoint 0 01-31-2010 10:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:52 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