Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-12-2018, 01:17 AM
datdude datdude is offline Changing figures' caption from bottom to above Windows 10 Changing figures' caption from bottom to above Office 2013
Novice
Changing figures' caption from bottom to above
 
Join Date: May 2018
Posts: 2
datdude is on a distinguished road
Default Changing figures' caption from bottom to above


I have many figures in my document, those figures have their captions at the bottom. I need to move the caption to above. How can I achieve that? preferably, change them in batch mode or macro. I found a macro online to change caption for tables from bottom to above, but couldn't get it to work with figures.

Code:
Sub UpdateTables()
Application.ScreenUpdating = False
Dim i As Long, oPrev As Range, oNext As Range
With ActiveDocument
  For i = .Tables.Count To 1 Step -1
    With .Tables(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

Last edited by Charles Kenyon; 05-12-2018 at 10:03 AM.
Reply With Quote
  #2  
Old 05-12-2018, 10:02 AM
Charles Kenyon Charles Kenyon is online now Changing figures' caption from bottom to above Windows 10 Changing figures' caption from bottom to above Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
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
  #3  
Old 05-12-2018, 10:21 AM
datdude datdude is offline Changing figures' caption from bottom to above Windows 10 Changing figures' caption from bottom to above Office 2013
Novice
Changing figures' caption from bottom to above
 
Join Date: May 2018
Posts: 2
datdude is on a distinguished road
Default

Thanks Charles. Yea I understand it won't work as it since it's looping over tables. I actually used this macro to update tables caption and it worked great. I tried to change "Tables" in macro but couldn't find exact one used for figures. I tried your version of code and unfortunately it didn't work. It says "Object doesn't support this property or method" and it's indicating "Figures"
Reply With Quote
  #4  
Old 05-12-2018, 05:57 PM
Charles Kenyon Charles Kenyon is online now Changing figures' caption from bottom to above Windows 10 Changing figures' caption from bottom to above Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
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

Try Objects.

Sorry, I'm kind of busy and am not trying to write your code.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
List of figures with several labels (caption) - Table of Figures sorting ibra_ca Word 2 10-11-2017 07:02 AM
Automatic table of figures includes one of the figures, not just the caption - help! sarahlt Word 1 09-28-2014 09:34 AM
Table of Figures repeats caption references. jorgensene Word 1 08-13-2014 03:51 PM
Using Insert Caption/List of figures rezza22 Word 2 05-12-2013 09:39 AM
Changing figures' caption from bottom to above Caption and Table of Figures issue reece22345 Word 3 04-15-2011 12:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft