![]() |
|
#1
|
|||
|
|||
|
Dear All!
Is it possible to use the AutoCaption function for existing tables? My Word document has so many tables without numbering and labelling, and I want use the AutoCaption for these tables. Is it possible to use AutoCaption for images? Maybe via VB macros? Thank you for reading and trying to help me! |
|
#2
|
|||
|
|||
|
No, you can not use AutoCaption for existing tables. It is automatic for NEW tables. You can add Caption though to existing tables using something like:
Code:
Sub addCAP() Dim oTbl As Table For Each oTbl In ActiveDocument.Tables oTbl.Select Selection.InsertCaption Label:="Table", TitleAutoText:="", Title:="", _ Position:=wdCaptionPositionAbove Next End Sub |
|
#3
|
|||
|
|||
|
Thank you fumei!
It works well with tables! I already had captions without label and number for my tables so I signed them with special characters (#table_caption_start# /...end#) then I searched these caption (With Selection.Find .Execute FindText:="#table_caption_start#",...) and used it at InsertCaption at Title. Here is the code: Code:
Sub addTableCAP2()
Dim objTable As Table
Dim rngTable As Range
Dim strTable As String
For Each objTable In ActiveDocument.Tables
With Selection.Find
.Execute FindText:="#table_caption_start#", Forward:=True, MatchWholeWord:=False, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False
Set rngTable = Selection.Range
rngTable.End = ActiveDocument.Range.End
rngTable.End = rngTable.Start + InStr(rngTable, "end#")
rngTable.End = rngTable.End + 4
strTable = Replace(rngTable.Text, "#table_caption_start#", "")
strTable = Replace(strTable, "#table_caption_end#", "")
strTable = Left(strTable, Len(strTable) - 1)
rngTable.Text = ""
objTable.Select
Selection.InsertCaption Label:="Table", TitleAutoText:="", Title:=" - " + strTable, _
Position:=wdCaptionPositionAbove
End With
Next
End Sub
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I add columns to existing tables? | dpcalder | Word | 1 | 08-06-2013 09:49 AM |
Edit of existing report
|
abbertonian | Project | 3 | 04-10-2013 07:56 AM |
| How to add to an existing animation | karenw | PowerPoint | 0 | 10-14-2011 05:51 AM |
| Formatting existing text | Kaila | Word | 0 | 09-03-2011 05:40 PM |
Updating Existing Information
|
akshaygopale | Office | 5 | 06-22-2011 06:07 AM |