M
Mark Tangard
I'm trying to have a macro place a small frame in the margin with the
baseline of its content aligned with the baseline of the first text line
of various anchoring paragraph. If all the anchoring paragraphs had the
same format specs, this would be easy, but they don't, so the frames
don't align consistently. I can't figure out what value(s) the
VerticalPosition property is added to. It seems vaguely related to the
anchoring paragraph's font size and/or SpaceBefore spec, but with no
pattern I can discern, except that bulleted paragraphs sometimes seem to
cause the frame to align considerably higher than desired. The frames
all contain one short line of text. How can I make the frame’s text
baseline the same as the baseline of the first line of the anchoring
paragraph? (Have tried the same thing using text boxes with similarly
befuddling results.)
My code:
Dim f As Frame, r As Range
Set r = Selection.Paragraphs(1).Range
r.Collapse wdCollapseStart
Set f = ActiveDocument.Frames.Add(r)
With f
.Borders(wdBorderBottom).Visible = False
.Borders(wdBorderTop).Visible = False
.Borders(wdBorderLeft).Visible = False
.Borders(wdBorderRight).Visible = False
.WidthRule = wdFrameExact
.HeightRule = wdFrameExact
.Width = 30
.Height = 16 'should this be roomy? tight? anchor pgph font size?
.Range.Text = "Hi!"
End With
f.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
f.HorizontalPosition = 36
f.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
f.VerticalPosition = p.SpaceBefore 'ehhh?
Thanks for any help.
MT
baseline of its content aligned with the baseline of the first text line
of various anchoring paragraph. If all the anchoring paragraphs had the
same format specs, this would be easy, but they don't, so the frames
don't align consistently. I can't figure out what value(s) the
VerticalPosition property is added to. It seems vaguely related to the
anchoring paragraph's font size and/or SpaceBefore spec, but with no
pattern I can discern, except that bulleted paragraphs sometimes seem to
cause the frame to align considerably higher than desired. The frames
all contain one short line of text. How can I make the frame’s text
baseline the same as the baseline of the first line of the anchoring
paragraph? (Have tried the same thing using text boxes with similarly
befuddling results.)
My code:
Dim f As Frame, r As Range
Set r = Selection.Paragraphs(1).Range
r.Collapse wdCollapseStart
Set f = ActiveDocument.Frames.Add(r)
With f
.Borders(wdBorderBottom).Visible = False
.Borders(wdBorderTop).Visible = False
.Borders(wdBorderLeft).Visible = False
.Borders(wdBorderRight).Visible = False
.WidthRule = wdFrameExact
.HeightRule = wdFrameExact
.Width = 30
.Height = 16 'should this be roomy? tight? anchor pgph font size?
.Range.Text = "Hi!"
End With
f.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
f.HorizontalPosition = 36
f.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
f.VerticalPosition = p.SpaceBefore 'ehhh?
Thanks for any help.
MT