Convert Pic to Table with Caption in Row 2

S

Steve

Hi, All. I'm using Word 2000 to write proposals with pictures, graphs, and
figures in them. I'd like to find the best way to insert a caption that is
grouped with the figure or graphic. Over the years, I've experimented with
all of Word's tools for figures & captions ("insert caption",
"cross-reference", etc) and have never been happy with them. I've concluded
that the best approach for me is to insert a table with one column, two
rows, paste the graphic into the first row and put a Sequence Field in the
second row for the caption. I set the first row height ("exactly") to match
the graphic height, set the second row height for the caption to exactly
0.4", set the column width to match the graphic width, turn the borders off,
apply "Para Keep With Next" to the first row and make sure both rows do not
break across pages.

As you can imagine, doing this manually for each graphic is a real pain in
the neck.

Is there a better approach to managing graphics and captions? Is my use of a
two-row table a clunky way to do this?

Or should I automate my manual procedure? I've started some automation
(below) and need help finishing it. Specifically, how do I insert the Seq
Field in the second row? Should I use "InsertCaption" instead of
"Fields.Add" to add the sequence? If I use InsertCaption then it goes below
my table, not into Row 2 where I'd like it to be. And how do I set the
column width to match the width of the graphic in the first row?

Thanks for any help!
Steve

Sub PutPicInTable()
Dim tbl As Table
Dim rw As Row

' Graphic is already selected when running macro.
Set tbl = Selection.ConvertToTable(Separator:=wdSeparateByParagraphs, _
NumColumns:=1, _
NumRows:=1, _
Format:=wdTableFormatNone, _
ApplyBorders:=False, _
ApplyShading:=False, _
ApplyFont:=True, _
ApplyColor:=True, _
ApplyHeadingRows:=True, _
ApplyLastRow:=False, _
ApplyFirstColumn:=True, _
ApplyLastColumn:=False, _
AutoFit:=True, _
AutoFitBehavior:=wdAutoFitFixed)

tbl.Rows.Add

For Each rw In tbl.Rows
rw.AllowBreakAcrossPages = False
Next

tbl.Borders.Enable = False
tbl.Rows(2).SetHeight RowHeight:=InchesToPoints(0.5), _
HeightRule:=wdRowHeightExactly

' How do I do the following? This doesn't work.
'tbl.Rows(2).Range.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:="SEQ Figure \* Arabic", _
PreserveFormatting:=True
End Sub
 
D

Doug Robbins - Word MVP

Select the table and create an autotext entry of it. To further facilitate
it's use, put the SEQ field in the table before selecting it so that it's
already in the table when you insert the autotext entry into the document.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
S

Steven Drenker

Doug...good idea. How do I get Cell1 height and width to match size of the
graphic pasted into the cell?
 
D

Doug Robbins - Word MVP

Hi Stephen,

You would need to run a macro after inserting the picture to do that. If
the cursor is in the table, use

Dim oheight As Single, owidth As Single
oheight = Selection.Tables(1).Cell(1, 1).Range.InlineShapes(1).Height
owidth = Selection.Tables(1).Cell(1, 1).Range.InlineShapes(1).Width
Selection.Tables(1).Cell(1, 1).Height = oheight
Selection.Tables(1).Cell(1, 1).Width = owidth


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top