Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Put border around a Picture

Status
Not open for further replies.

danielmare

Technical User
May 10, 2011
4
AU
I'm using MS Office 2011 for Mac.

When I record a macro and put a border around an image, the macro records nothing. Attempting to simply program a macro, I tried the following:

For Each pic In ActiveDocument.InlineShapes
pic.Item.Borders '.blabla
pic.Item.ConvertToShape

Both Item.Borders and Item.ConvertToShape is not supported by the Picture object it seems:

Run time error '438'
Object doesn't support this property or method.

What is the actual property for picture borders??
 
Hi Daniel,

There is no 'Item' for an InlineShape, so:
Code:
Dim pic As InlineShape
For Each pic In ActiveDocument.InlineShapes
  pic.Borders
Next
and, after 'Borders' add whatever the next property is you want to apply (eg pic.Borders.DistanceFromBottom = 1_

Cheers
Paul Edstein
[MS MVP - Word]
 
Thank you for your reply Paul.

I have tried as you suggested, but the following line:
pic.Borders.OutsideLineWidth = wdLineWidth600pt
simply results in Run-time error '5843':
One of the values passed to this method or property is out of range.

Tried differnet values for above property - same error. All values tried come from the drop-down list that automatically appears.

The following lines:
pic.Borders.OutsideColor = wdColorBlack
pic.Borders.OutsideLineStyle = wdLineStyleSingle
Simply bring up the "Format Picture" window, but don't actually change any properties themselves.

Not sure if behaviour is perhaps different in Word 2010 for Windows - perhaps it's a Office for Mac quirk.

Also, I've noticed behaviour is different in compatiblity mode, but I'm trying to get this to work in .docx documents.

Any ideas?
 
Hi Daniel,

Evidently your inlineshapes don't have any borders applied. You must apply a border before you can adjust its thickness!

Try:
Code:
Sub Test()
Dim pic As InlineShape
For Each pic In ActiveDocument.InlineShapes
  pic.Borders.OutsideLineStyle = wdLineStyleSingle
  pic.Borders.OutsideLineWidth = wdLineWidth600pt
Next
End Sub
Note: depending on which OutsideLineStyle you choose, some weights etc might not be allowed.

Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top