View Single Post
 
Old 02-11-2014, 05:46 AM
Navis Navis is offline Windows XP Office 2010 64bit
Novice
 
Join Date: Feb 2014
Posts: 1
Navis is on a distinguished road
Post Macro to add captions to pictures inside word document

Hi,

I am very new to VB and Macros. I have around 100 images in my document and i need to assign format style "Captions" to all my images and insert Figure Captions below images as "Figure 1: <<Insert Titele Here>>".

I recorded macro and my macro look like below and unable to loop this for entire document.

Sub Macro1()
'
' Macro1 Macro
'
'
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^g"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Style = ActiveDocument.Styles("Caption")
Selection.InsertCaption Label:="Figure", TitleAutoText:="InsertCaption1", _
Title:="", Position:=wdCaptionPositionBelow, ExcludeLabel:=0
End Sub
Reply With Quote