The exercise is to determine whether a range of text fits on to a single line in the document (and if not, then reduce the style font size until it DOES fit on one line).
As far as I can see "selection.Information(wdFirstCharacterLineNumber)" will tell me the line number at the start of a selection (or range), but there is no "selection.Information(wdLastCharacterLineNumber)".
To determine the line number at the end of the selection, I would fabricate a range for the character beyond my selection and test that for range.Information(wdFirstCharacterLineNumber) and then compare or subtract the two.
Determine line number in word 2003 document
-
- PlutoniumLounger
- Posts: 15734
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Determine line number in word 2003 document
By definition, educating the client is the consultant’s first objective
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: Determine line number in word 2003 document
Yes. Similar idea:
Code: Select all
Function ParaHasMultipleLines(par As Word.Paragraph) As Boolean
Dim rngEnd As Word.Range
Set rngEnd = ActiveDocument.Range(Start:=par.Range.End - 1, End:=par.Range.End - 1)
If par.Range.Information(wdFirstCharacterLineNumber) <> _
rngEnd.Information(wdFirstCharacterLineNumber) Then
ParaHasMultipleLines = True
End If
Set rngEnd = Nothing
End Function
-
- PlutoniumLounger
- Posts: 15734
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Determine line number in word 2003 document
Jefferson thanks for the quick European-style confirmation (I refer to the blue skiing jacket).jscher2000 wrote:Yes. Similar idea:
I am fascinated to see that you pass a paragraph.
I embarked with a Selection.Range then quickly dropped back to a Selection.Range.Paragraphs(1).Range which works for my limited application:
Code: Select all
Function lngLineEnd(ByVal rng As Range) As Long
Dim rng2 As Range
Set rng2 = rng
rng2.Start = rng.End + 1
lngLineEnd = rng2.Information(wdFirstCharacterLineNumber) - 1
'Sub TESTlngLineEnd()
' MsgBox lngLineEnd(Selection.Range)
'End Sub
End Function
You do not have the required permissions to view the files attached to this post.
By definition, educating the client is the consultant’s first objective
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: Determine line number in word 2003 document
Actually it's a tight-fitting "rash guard" used to reduce sun exposure during snorkeling. I won't be posting photos of the stomach area of this garment.ChrisGreaves wrote:(I refer to the blue skiing jacket)
-
- PlutoniumLounger
- Posts: 15734
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Determine line number in word 2003 document
Speaking of rash decisions, I posted my efforts as a technical paper, and http://www.chrisgreaves.com/Invitations/PseudoCode.htm has a scanned image of my pseudo code.jscher2000 wrote: ... tight-fitting "rash guard" ...
I realized that I wanted to
- Bump up font size to fit the print area
- Reduce font size so that the data lines (name, address, date) didn't overflow their line
- Bump up paragraph spacing to fit the print area.
Results at the foot of the pseudo code page. Source Code (Word 2003 VBA) available on request.
The envelope should be a pushover.
By definition, educating the client is the consultant’s first objective