Table Caption Name "capture" 
Author Message
 Table Caption Name "capture"

Where is the caption - immediately above? immediately below?  Is is always a
single line?  Is it stylized (Caption) to confirm that it is a caption?

I threw in a few lines in the code below (between the ### signs) to get the
l paragraph immediately above the table.  You might want to confirm the
style.

Colleen

Quote:
> Sub Test()

> Dim i As Integer
> Dim tblSpec As Table

> Open "C:\TEMP\TESTFILE.TXT" For Output As #1

> Write #1, "Tables: " & CStr(ActiveDocument.Tables.Count)
> For Each tblSpec In ActiveDocument.Tables

> ###

        tblspec.Select
        Selection.MoveUp Unit:=wdLine, Count:=1
        Selection.Paragraphs(1).Range.Select
        Write #1, "Paragraph immediately above table " & selection

Quote:
> ###
>     Write #1, "Contents of First Cell: " & tblSpec.Cell(1, 1).Range.Text
>     Write #1, "Columns: " & CStr(tblSpec.Columns.Count)
>     Write #1, "Rows: " & CStr(tblSpec.Rows.Count)
>     Write #1, ""
> Next

> Close #1

> End Sub



Quote:
> Thanks to Michael frank i know can access Table data from VB.

> I am having trouble working out how to read the Caption text associated
> with a table.
> [you see i need to look for tables with a specific name].
> I have found help about setting the name, but not reading it.
> Can you help ?

> Thanks in advance.

> Sub Test()

> Dim i As Integer
> Dim tblSpec As Table

> Open "C:\TEMP\TESTFILE.TXT" For Output As #1

> Write #1, "Tables: " & CStr(ActiveDocument.Tables.Count)
> For Each tblSpec In ActiveDocument.Tables

> ### Read caption for this Table somehow ????

>     Write #1, "Contents of First Cell: " & tblSpec.Cell(1, 1).Range.Text
>     Write #1, "Columns: " & CStr(tblSpec.Columns.Count)
>     Write #1, "Rows: " & CStr(tblSpec.Rows.Count)
>     Write #1, ""
> Next

> Close #1

> End Sub

> Greg Roberts (Ext: 7109)

> Citect Senior Device Driver Developer
> Ci Technologies Pty Ltd

> Phone: +61 2 9855 1000
> Fax: +61 2 9488 9164
> Web: http://www.*-*-*.com/



Mon, 18 Nov 2002 03:00:00 GMT  
 Table Caption Name "capture"
Have you used a unique style for table captions?

--
Suzanne S. Barnhill
Microsoft Word MVP
Words into Type
Fairhope, AL USA


Quote:
> Thanks to Michael frank i know can access Table data from VB.

> I am having trouble working out how to read the Caption text associated
> with a table.
> [you see i need to look for tables with a specific name].
> I have found help about setting the name, but not reading it.
> Can you help ?

> Thanks in advance.

> Sub Test()

> Dim i As Integer
> Dim tblSpec As Table

> Open "C:\TEMP\TESTFILE.TXT" For Output As #1

> Write #1, "Tables: " & CStr(ActiveDocument.Tables.Count)
> For Each tblSpec In ActiveDocument.Tables

> ### Read caption for this Table somehow ????

>     Write #1, "Contents of First Cell: " & tblSpec.Cell(1, 1).Range.Text
>     Write #1, "Columns: " & CStr(tblSpec.Columns.Count)
>     Write #1, "Rows: " & CStr(tblSpec.Rows.Count)
>     Write #1, ""
> Next

> Close #1

> End Sub

> Greg Roberts (Ext: 7109)

> Citect Senior Device Driver Developer
> Ci Technologies Pty Ltd

> Phone: +61 2 9855 1000
> Fax: +61 2 9488 9164
> Web: http://www.cit.com.au/



Mon, 18 Nov 2002 03:00:00 GMT  
 Table Caption Name "capture"
Thanks to Michael frank i know can access Table data from VB.

I am having trouble working out how to read the Caption text associated
with a table.
[you see i need to look for tables with a specific name].
I have found help about setting the name, but not reading it.
Can you help ?

Thanks in advance.

Sub Test()

Dim i As Integer
Dim tblSpec As Table

Open "C:\TEMP\TESTFILE.TXT" For Output As #1

Write #1, "Tables: " & CStr(ActiveDocument.Tables.Count)
For Each tblSpec In ActiveDocument.Tables

### Read caption for this Table somehow ????

    Write #1, "Contents of First Cell: " & tblSpec.Cell(1, 1).Range.Text
    Write #1, "Columns: " & CStr(tblSpec.Columns.Count)
    Write #1, "Rows: " & CStr(tblSpec.Rows.Count)
    Write #1, ""
Next

Close #1

End Sub

Greg Roberts (Ext: 7109)

Citect Senior Device Driver Developer
Ci Technologies Pty Ltd

Phone: +61 2 9855 1000
Fax: +61 2 9488 9164
Web: http://www.cit.com.au/



Tue, 19 Nov 2002 03:00:00 GMT  
 Table Caption Name "capture"

p.s. Is there another way (invisibly) to tag a table to
make it unique (as seen by VB) besides some fixed string in the Table Header
row ?

Thanks



Tue, 19 Nov 2002 03:00:00 GMT  
 Table Caption Name "capture"
Use Bookmarks?

Table objects don't have a name property - wish they did!

Regards

Dave


|
| p.s. Is there another way (invisibly) to tag a table to
| make it unique (as seen by VB) besides some fixed string in the Table
Header
| row ?
|
| Thanks
|
|



Tue, 19 Nov 2002 03:00:00 GMT  
 Table Caption Name "capture"
Thanks. Ok so i though a table had an associated name "Figure 1. My Cats"
and the
caption was associated with the table.

Looks like they are seperate. Bummer Dave.

Suzanne, I' a novice here and don't know about uique styles.

From memory a bookmark lives my itself so you need some smart logic
like what Michael showed, to get a bookmark at the same level
as the top of your table.

Quote:
>> How would this be changed for to "capture" a bookmark ??

        tblspec.Select
        Selection.MoveUp Unit:=wdLine, Count:=1
        Selection.Paragraphs(1).Range.Select
        Write #1, "Paragraph immediately above table " & selection

Thanks and all have good weekends.

Regards



Tue, 19 Nov 2002 03:00:00 GMT  
 Table Caption Name "capture"
Greg:

If you are fiddling around in VBA your are *not* a novice.

What Suzanne was asking was "Have you applied a style to your caption
paragraphs?"  By default, Word applies the "Caption" style.  Documentation
professionals usually create a style for Tables and one for Figures:
Caption Table and Caption Figure.  If you do that, you can then get your
code to walk back up the table looking for the first paragraph with a style
of "Caption Table" that it finds.  That's the caption!

However, since you ARE playing around in VBA, there's an easier way to do
it, using the Paragraphs collection.  Something like:

Dim aCaption As String
Dim aPara As Paragraph
For Each aPara In ActiveDocument.Paragraphs
    If aPara.Style = wdStyleCaption Then
    isItATable = aPara.Range.Text Like "Table*"
        If isItATable = True Then
            MsgBox aPara.Range.Text
            End
        End If
    End If
Next aPara

Note, I have not run or tested this code, you will have to tweak it.

If you want to get smart, you can create a similar structure to list all the
Tables in the ActiveDocument.Tables collection.  The Item method of the
tables collection will return a number indicating the position of the table
from the front of the document.

The code snippet above enables you to read the front of the caption.  If you
take the number you get from the table, insert it into a string variable and
insert that in the code above, you can find the caption belonging to the
specific table you are interested in.

In a big document, you would do well to select the table, return its range,
then extend the range two paragraphs upwards, and inspect the range for the
caption.  Otherwise it will take too long to enumerate all the paragraphs in
the document.  You have a fair idea where the one you want is :-)

Hope this helps.

In microsoft.public.word.tables on Fri, 2 Jun 2000 16:04:39 +1000, "Greg

Quote:

> Thanks. Ok so i though a table had an associated name "Figure 1. My Cats"
> and the
> caption was associated with the table.

> Looks like they are seperate. Bummer Dave.

> Suzanne, I' a novice here and don't know about uique styles.

> From memory a bookmark lives my itself so you need some smart logic
> like what Michael showed, to get a bookmark at the same level
> as the top of your table.
> >> How would this be changed for to "capture" a bookmark ??

>         tblspec.Select
>         Selection.MoveUp Unit:=wdLine, Count:=1
>         Selection.Paragraphs(1).Range.Select
>         Write #1, "Paragraph immediately above table " & selection

> Thanks and all have good weekends.

> Regards

Please post follow-up questions to the newsgroup so that all may follow the thread.


Consultant Technical Writer
Microsoft MVP (Word)
Sydney, Australia (GMT +10 hrs) +61 (04) 1209 1410



Wed, 27 Nov 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Problem with dot file names ".name"

2. Getting "?" button on the caption bar

3. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

4. Capturing the PRINT "Event"

5. "Capture" Tab Position

6. Capturing "Edit" Event

7. Capturing SQL Server "Raiserror" in VB

8. Capturing "EMF" files

9. Capturing "EMF" files

10. capture "open in new window"

 

 
Powered by phpBB® Forum Software