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
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