For some reason my macros disappeared in the last week or so from my Normal template. I'm blaming a MS update but who knows? I got lucky and was able to retrieve my photo manipulating macro text from an email, but unfortunately it no longer works, details follow:
I have been happily selecting a photo and using the following macro in Word to resize, add a border and add a sequential caption starter in the form "Photo xx: ". It now fails with the runtime error 4198 when inserting the caption.
I have tried to insert the caption manually (References/Insert Caption) and see there is no Photo option available in the Label dropdown menu (see attached screenshot).
Thanks in advance to any welcome assistance with this.
Code:
Sub PhotoResize()
'
' PhotoResize Macro
'
With Selection.InlineShapes(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
.Borders.Shadow = False
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = wdColorAutomatic
End With
'Resize photo
Selection.InlineShapes(1).Height = 283.45
Selection.InlineShapes(1).Width = 378.15
'Remove space below photo
Selection.ParagraphFormat.SpaceAfter = 0
'Insert caption
Selection.InsertCaption Label:="Photo", TitleAutoText:="InsertCaption1", _
Title:="", Position:=wdCaptionPositionBelow, ExcludeLabel:=0
'Turn off bold
Selection.MoveLeft Unit:=wdCharacter, Count:=8, Extend:=wdExtend
Selection.Font.Bold = wdToggle
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:=": "
'Carriage return
Selection.TypeParagraph
End Sub