Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 09-04-2013, 02:34 AM
ragesz ragesz is offline How to AutoCaption existing tables Windows 7 64bit How to AutoCaption existing tables Office 2007
Novice
How to AutoCaption existing tables
 
Join Date: Oct 2012
Posts: 14
ragesz is on a distinguished road
Default

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
Reply With Quote
 



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
How to AutoCaption existing tables 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
How to AutoCaption existing tables Updating Existing Information akshaygopale Office 5 06-22-2011 06:07 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:33 PM.


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