View Single Post
 
Old 08-27-2021, 04:20 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The issue is that your figure captions are not in the main body of the document. Your example has the graphic floating and the caption is sitting in a text frame. To solve that, you need the macro to find the storyranges which might contain an entry.
Code:
Sub ReplaceCaptionStyle()
' Developed by Andrew Lockton (Guessed)
' Edited by laith93
' www.msofficeforums.com
  Dim aRng As Range

' Showing all field codes (or by pressing Alt-F9):
  ActiveWindow.View.ShowFieldCodes = True
  
  For Each aRng In ActiveDocument.StoryRanges
    With aRng.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      ' Replace "CapTbl" with your own alternative caption style for tables
      .Replacement.Style = ActiveDocument.Styles("CapTbl")
      .Text = "seq table"
      .Forward = True
      .Wrap = wdFindContinue
      .Format = True
      .MatchCase = False
      .MatchWholeWord = False
      .MatchKashida = False
      .MatchDiacritics = False
      .MatchAlefHamza = False
      .MatchControl = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Execute Replace:=wdReplaceAll
      
      ' Replace "CapFig" with your own alternative caption style for figures
      .Replacement.ClearFormatting
      .Replacement.Style = ActiveDocument.Styles("CapFig")
      .Text = "seq figure"
      .Execute Replace:=wdReplaceAll
    End With
  Next aRng
    
  ' Hiding all field codes (or by pressing Alt-F9):
  ActiveWindow.View.ShowFieldCodes = False
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote