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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

word 2010 VBA setting a selected image to border and text wrap tight 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have this code but it does not work all the time. the top part worked once to set the text wrap. but now I get this error:
Error #5941
The requested member of the collection does not exist
I want to highlight an image in the document, then click a Quick Access Toolbar button and have it put a border of 1.5 and text wrap, "tight". and... also text wrap, top and bottom (for another macro) [bigsmile]
TIA
Code:
Sub ImageAddFrame_TextWrapTB()
' format picture text tight
    Selection.InlineShapes(1).ConvertToShape
    Selection.ShapeRange.WrapFormat.Type = wdWrapTight
    
    'add border
    'With Selection.InlineShapes(1)
        Selection.InlineShapes(1).Borders.OutsideLineStyle = wdLineStyleSingle
        Selection.InlineShapes(1).Borders.OutsideLineWidth = wdLineWidth150pt
    'End With
End Sub

DougP
 
Why converting the InLineShape to Shape ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
No clue, I just grabbed code from the google gods and pasted it in.
what should I be doing?

DougP
 
Ok I got this far; it makes the image text warp tight.
But need help inserting a border around the image.
Getting error on this line> Selection.Borders.OutsideLineStyle = wdLineStyleSingle

Code:
    Selection.InlineShapes(1).ConvertToShape
    Selection.ShapeRange.WrapFormat.Type = wdWrapTight

  [highlight #FCE94F]  Selection.Borders.OutsideLineStyle = wdLineStyleSingle[/highlight]
    'Selection.Borders.LineWidth = wdLineWidth150pt  ' these are "Compile error";
 Method or data memeber not found

    'Selection.Borders.Color = wdColorAutomatic

TIA

DougP
 
What about this ?
Code:
Sub ImageAddFrame_TextWrapTB()
With Selection.InlineShapes(1)
    .Borders.OutsideLineStyle = wdLineStyleSingle
    .Borders.OutsideLineWidth = wdLineWidth150pt
    .ConvertToShape
End With
Selection.ShapeRange.WrapFormat.Type = wdWrapTight
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Works Awesome baby, Awesome !!!

[r2D2]
[trooper]

DougP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top