View Single Post
 
Old 05-12-2018, 10:02 AM
Charles Kenyon Charles Kenyon is offline Windows 10 Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,533
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I do not know that this will work, but know that looping through the tables won't change anything for non-tables.

Try:
Code:
Sub UpdateFigureCaptions()
Application.ScreenUpdating = False
' Charles Kenyon
Dim i As Long, oPrev As Range, oNext As Range
With ActiveDocument
  For i = .Figures.Count To 1 Step -1
    With .Figures(i).Range
      Set oPrev = .Characters.First.Previous.Characters.Last
      Set oNext = .Characters.Last.Next.Paragraphs.First.Range
      With oPrev
        .InsertBefore vbCr
        .Start = .End - 1
        .Style = oNext.Style
        .End = .Start
        If Len(oNext.Text) > 1 Then
          With oNext
            .End = .End - 1
            .Cut
            .Delete
          End With
          .Paste
        Else
          oNext.Delete
        End If
      End With
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
Reply With Quote