View Single Post
 
Old 09-13-2019, 11:23 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 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

It is a question of setting the range appropriately e.g.

Code:
Sub FormatImages()
Dim i As Integer
Dim oInlineShp As InlineShape
Dim oRng As Range
    For i = 1 To ActiveDocument.InlineShapes.Count
        Set oInlineShp = ActiveDocument.InlineShapes(i)
        With oInlineShp
            If .Borders(wdBorderTop).LineStyle = wdLineStyleNone Then
                .Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
                .Borders(wdBorderLeft).LineWidth = wdLineWidth225pt
                .Borders(wdBorderRight).LineStyle = wdLineStyleSingle
                .Borders(wdBorderRight).LineWidth = wdLineWidth225pt
                .Borders(wdBorderTop).LineStyle = wdLineStyleSingle
                .Borders(wdBorderTop).LineWidth = wdLineWidth225pt
                .Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
                .Borders(wdBorderBottom).LineWidth = wdLineWidth225pt
                Set oRng = .Range
                oRng.InsertAfter vbCr
                oRng.End = oRng.Paragraphs.Last.Range.Next.Paragraphs(1).Range.End - 1
                oRng.Collapse 0
                oRng.ParagraphFormat.Alignment = wdAlignParagraphCenter
                oRng.Text = "Foto " & i
                oRng.Font.Bold = True
            End If
        End With
    Next i
    Set oInlineShp = Nothing
    Set oRng = Nothing
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