View Single Post
 
Old 09-13-2019, 07:15 AM
Dzib Dzib is offline Windows 10 Office 2019
Novice
 
Join Date: Jul 2019
Posts: 29
Dzib is on a distinguished road
Default Add a text below pictures

Hi,

I have this little code to add borders to pictures in a word doc and a little text below (like a caption with a number but couldn't find out how to reset captions index each time the macro is run so I made it this way)

Sub FormatImages()

Dim i As Integer
Dim oInlineShp As InlineShape

i = 0

For Each oInlineShp In ActiveDocument.InlineShapes
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
i = i + 1
.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Range.InsertAfter vbCr & "Foto " & i & vbCr
.Range.Font.Bold = True
End If
End With
Next

End Sub

It works fine except that I would like to format (bold) the text inserted... I can't find out how to do that.
Range.font.bold = true doesn't work.

[Code] doesn't work from my smartphone, sorry

Edit: I just found a solution using the sélection method, extending the selection 2 lines down and formatting the whole selection 😉
Reply With Quote