Group:  Microsoft Word ยป microsoft.public.word.vba.general
Thread: Points returned by Information(wdHorizontalPosition...)

Points returned by Information(wdHorizontalPosition...)
Charlie''s Word VBA questions 10/24/2005 10:25:04 AM
In a macro, the value returned by
"Selection.Information(wdHorizontalPosition..." and
"Selection.Information(wdVerticalPosition...)" is in points, even though the
help says the value is in twips. I assume that the function is accurate.
Should the returned value be rounded or truncated or used exactly as
returned? For example, if a paragraph is indented 0.5 inches, the returned
value is 36.0 points which computes to an actual indent of 0.5 inches.
However, if the paragraph is indented 0.25 inches, the returned value is
18.45 points which computes to exactly 0.25625 inches.
Can Word actually do its metrics in fractions of points and, for that
matter, in fractions of twips? When returned values are converted to twips,
occassionally the answer is in fractions of twips. I have double- and
triple-checked the calculations and for multiples of 1/2 inch (0.0, 0.5, 1.0,
etc.), the results are always perfect.
Thanks for your help.
Re: Points returned by Information(wdHorizontalPosition...)
"Jezebel" <warcrimes[ at ]whitehouse.gov> 10/24/2005 12:24:17 PM
You've misread the Help file. Information() returns points, not twips ...

wdHorizontalPositionRelativeToPage Returns the horizontal position of the
specified selection or range; this is the distance from the left edge of the
selection or range to the left edge of the page measured in points (1 point
= 20 twips, 72 points = 1 inch). If the selection or range isn't within the
screen area, returns - 1.

wdVerticalPositionRelativeToPage Returns the vertical position of the
selection or range; this is the distance from the top edge of the selection
to the top edge of the page measured in points (1 point = 20 twips, 72
points = 1 inch). If the selection isn't visible in the document window,
returns - 1.


Separately, I think there must be something interfering with your
positioning, rather than internal conversion problems. I normally work in
millimetres (so these measurements are never exact); but I just tried
changing to inches and setting the margin to 0.25 inches.
selection.Information(wdHorizontalPositionRelativeToPage) returns exactly
18, as expected.





"Charlie''s Word VBA questions"
<CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
news:5B984BAC-ADE3-4467-B97B-FEF51711A4C0[ at ]microsoft.com...
[Quoted Text]
> In a macro, the value returned by
> "Selection.Information(wdHorizontalPosition..." and
> "Selection.Information(wdVerticalPosition...)" is in points, even though
> the
> help says the value is in twips. I assume that the function is accurate.
> Should the returned value be rounded or truncated or used exactly as
> returned? For example, if a paragraph is indented 0.5 inches, the
> returned
> value is 36.0 points which computes to an actual indent of 0.5 inches.
> However, if the paragraph is indented 0.25 inches, the returned value is
> 18.45 points which computes to exactly 0.25625 inches.
> Can Word actually do its metrics in fractions of points and, for that
> matter, in fractions of twips? When returned values are converted to
> twips,
> occassionally the answer is in fractions of twips. I have double- and
> triple-checked the calculations and for multiples of 1/2 inch (0.0, 0.5,
> 1.0,
> etc.), the results are always perfect.
> Thanks for your help.


Re: Points returned by Information(wdHorizontalPosition...)
Charlie''s Word VBA questions 10/24/2005 8:25:02 PM
Yes, I misread the Help. Thank you.
I did some more experimenting with this. I would bet that in your test, the
zoom was 100%. If you change the zoom to, say, 90%, the number of points
will be 18.45 in the paragraph is indented .25 inches.

"Jezebel" wrote:

[Quoted Text]
> You've misread the Help file. Information() returns points, not twips ...
>
> wdHorizontalPositionRelativeToPage Returns the horizontal position of the
> specified selection or range; this is the distance from the left edge of the
> selection or range to the left edge of the page measured in points (1 point
> = 20 twips, 72 points = 1 inch). If the selection or range isn't within the
> screen area, returns - 1.
>
> wdVerticalPositionRelativeToPage Returns the vertical position of the
> selection or range; this is the distance from the top edge of the selection
> to the top edge of the page measured in points (1 point = 20 twips, 72
> points = 1 inch). If the selection isn't visible in the document window,
> returns - 1.
>
>
> Separately, I think there must be something interfering with your
> positioning, rather than internal conversion problems. I normally work in
> millimetres (so these measurements are never exact); but I just tried
> changing to inches and setting the margin to 0.25 inches.
> selection.Information(wdHorizontalPositionRelativeToPage) returns exactly
> 18, as expected.
>
>
>
>
>
> "Charlie''s Word VBA questions"
> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
> news:5B984BAC-ADE3-4467-B97B-FEF51711A4C0[ at ]microsoft.com...
> > In a macro, the value returned by
> > "Selection.Information(wdHorizontalPosition..." and
> > "Selection.Information(wdVerticalPosition...)" is in points, even though
> > the
> > help says the value is in twips. I assume that the function is accurate.
> > Should the returned value be rounded or truncated or used exactly as
> > returned? For example, if a paragraph is indented 0.5 inches, the
> > returned
> > value is 36.0 points which computes to an actual indent of 0.5 inches.
> > However, if the paragraph is indented 0.25 inches, the returned value is
> > 18.45 points which computes to exactly 0.25625 inches.
> > Can Word actually do its metrics in fractions of points and, for that
> > matter, in fractions of twips? When returned values are converted to
> > twips,
> > occassionally the answer is in fractions of twips. I have double- and
> > triple-checked the calculations and for multiples of 1/2 inch (0.0, 0.5,
> > 1.0,
> > etc.), the results are always perfect.
> > Thanks for your help.
>
>
>
Re: Points returned by Information(wdHorizontalPosition...)
"Jezebel" <warcrimes[ at ]whitehouse.gov> 10/26/2005 10:20:21 AM
You're right that Selection.Information() is affected by the zoom. I haven't
tested it in detail, but a rudimentary test shows different results.
However, that also suggests a workaround:

Selection.RANGE.Information() is *not* (it appears, again on a quick test)
affected by zoom.






"Charlie''s Word VBA questions"
<CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
news:2752C49F-210A-469B-BAB2-3F6B9198D62A[ at ]microsoft.com...
[Quoted Text]
> Yes, I misread the Help. Thank you.
> I did some more experimenting with this. I would bet that in your test,
> the
> zoom was 100%. If you change the zoom to, say, 90%, the number of points
> will be 18.45 in the paragraph is indented .25 inches.
>
> "Jezebel" wrote:
>
>> You've misread the Help file. Information() returns points, not twips ...
>>
>> wdHorizontalPositionRelativeToPage Returns the horizontal position of the
>> specified selection or range; this is the distance from the left edge of
>> the
>> selection or range to the left edge of the page measured in points (1
>> point
>> = 20 twips, 72 points = 1 inch). If the selection or range isn't within
>> the
>> screen area, returns - 1.
>>
>> wdVerticalPositionRelativeToPage Returns the vertical position of the
>> selection or range; this is the distance from the top edge of the
>> selection
>> to the top edge of the page measured in points (1 point = 20 twips, 72
>> points = 1 inch). If the selection isn't visible in the document window,
>> returns - 1.
>>
>>
>> Separately, I think there must be something interfering with your
>> positioning, rather than internal conversion problems. I normally work in
>> millimetres (so these measurements are never exact); but I just tried
>> changing to inches and setting the margin to 0.25 inches.
>> selection.Information(wdHorizontalPositionRelativeToPage) returns exactly
>> 18, as expected.
>>
>>
>>
>>
>>
>> "Charlie''s Word VBA questions"
>> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
>> news:5B984BAC-ADE3-4467-B97B-FEF51711A4C0[ at ]microsoft.com...
>> > In a macro, the value returned by
>> > "Selection.Information(wdHorizontalPosition..." and
>> > "Selection.Information(wdVerticalPosition...)" is in points, even
>> > though
>> > the
>> > help says the value is in twips. I assume that the function is
>> > accurate.
>> > Should the returned value be rounded or truncated or used exactly as
>> > returned? For example, if a paragraph is indented 0.5 inches, the
>> > returned
>> > value is 36.0 points which computes to an actual indent of 0.5 inches.
>> > However, if the paragraph is indented 0.25 inches, the returned value
>> > is
>> > 18.45 points which computes to exactly 0.25625 inches.
>> > Can Word actually do its metrics in fractions of points and, for that
>> > matter, in fractions of twips? When returned values are converted to
>> > twips,
>> > occassionally the answer is in fractions of twips. I have double- and
>> > triple-checked the calculations and for multiples of 1/2 inch (0.0,
>> > 0.5,
>> > 1.0,
>> > etc.), the results are always perfect.
>> > Thanks for your help.
>>
>>
>>


Re: Points returned by Information(wdHorizontalPosition...)
Charlie''s Word VBA questions 10/26/2005 11:11:03 AM
Thank you. I had a problem with using Range, perhaps because I didn't use it
in all places I needed to. The macro I have gets the distance from the paper
left, the left margin, top of page, from top margin, from right margin, etc.
My macro executes nearly instantly, so I have used the following code. I
also use this method in other macros to get the user's settings, then restore
them when the macro ends.
'Zoom percent
CurrZoom = ActiveDocument.ActiveWindow.View.Zoom
ActiveDocument.ActiveWindow.View.Zoom = 100
---------
'Restore Zoom
ActiveDocument.ActiveWindow.View.Zoom = CurrZoom


"Jezebel" wrote:

[Quoted Text]
> You're right that Selection.Information() is affected by the zoom. I haven't
> tested it in detail, but a rudimentary test shows different results.
> However, that also suggests a workaround:
>
> Selection.RANGE.Information() is *not* (it appears, again on a quick test)
> affected by zoom.
>
>
>
>
>
>
> "Charlie''s Word VBA questions"
> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
> news:2752C49F-210A-469B-BAB2-3F6B9198D62A[ at ]microsoft.com...
> > Yes, I misread the Help. Thank you.
> > I did some more experimenting with this. I would bet that in your test,
> > the
> > zoom was 100%. If you change the zoom to, say, 90%, the number of points
> > will be 18.45 in the paragraph is indented .25 inches.
> >
> > "Jezebel" wrote:
> >
> >> You've misread the Help file. Information() returns points, not twips ...
> >>
> >> wdHorizontalPositionRelativeToPage Returns the horizontal position of the
> >> specified selection or range; this is the distance from the left edge of
> >> the
> >> selection or range to the left edge of the page measured in points (1
> >> point
> >> = 20 twips, 72 points = 1 inch). If the selection or range isn't within
> >> the
> >> screen area, returns - 1.
> >>
> >> wdVerticalPositionRelativeToPage Returns the vertical position of the
> >> selection or range; this is the distance from the top edge of the
> >> selection
> >> to the top edge of the page measured in points (1 point = 20 twips, 72
> >> points = 1 inch). If the selection isn't visible in the document window,
> >> returns - 1.
> >>
> >>
> >> Separately, I think there must be something interfering with your
> >> positioning, rather than internal conversion problems. I normally work in
> >> millimetres (so these measurements are never exact); but I just tried
> >> changing to inches and setting the margin to 0.25 inches.
> >> selection.Information(wdHorizontalPositionRelativeToPage) returns exactly
> >> 18, as expected.
> >>
> >>
> >>
> >>
> >>
> >> "Charlie''s Word VBA questions"
> >> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
> >> news:5B984BAC-ADE3-4467-B97B-FEF51711A4C0[ at ]microsoft.com...
> >> > In a macro, the value returned by
> >> > "Selection.Information(wdHorizontalPosition..." and
> >> > "Selection.Information(wdVerticalPosition...)" is in points, even
> >> > though
> >> > the
> >> > help says the value is in twips. I assume that the function is
> >> > accurate.
> >> > Should the returned value be rounded or truncated or used exactly as
> >> > returned? For example, if a paragraph is indented 0.5 inches, the
> >> > returned
> >> > value is 36.0 points which computes to an actual indent of 0.5 inches.
> >> > However, if the paragraph is indented 0.25 inches, the returned value
> >> > is
> >> > 18.45 points which computes to exactly 0.25625 inches.
> >> > Can Word actually do its metrics in fractions of points and, for that
> >> > matter, in fractions of twips? When returned values are converted to
> >> > twips,
> >> > occassionally the answer is in fractions of twips. I have double- and
> >> > triple-checked the calculations and for multiples of 1/2 inch (0.0,
> >> > 0.5,
> >> > 1.0,
> >> > etc.), the results are always perfect.
> >> > Thanks for your help.
> >>
> >>
> >>
>
>
>
Re: Points returned by Information(wdHorizontalPosition...)
"Jezebel" <warcrimes[ at ]whitehouse.gov> 10/27/2005 9:23:00 AM
You'd do better learning to use Range objects. Almost all code runs quicker
and more reliably.




"Charlie''s Word VBA questions"
<CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
news:FF17A75F-7353-438B-B236-8969ABCD6422[ at ]microsoft.com...
[Quoted Text]
> Thank you. I had a problem with using Range, perhaps because I didn't use
> it
> in all places I needed to. The macro I have gets the distance from the
> paper
> left, the left margin, top of page, from top margin, from right margin,
> etc.
> My macro executes nearly instantly, so I have used the following code. I
> also use this method in other macros to get the user's settings, then
> restore
> them when the macro ends.
> 'Zoom percent
> CurrZoom = ActiveDocument.ActiveWindow.View.Zoom
> ActiveDocument.ActiveWindow.View.Zoom = 100
> ---------
> 'Restore Zoom
> ActiveDocument.ActiveWindow.View.Zoom = CurrZoom
>
>
> "Jezebel" wrote:
>
>> You're right that Selection.Information() is affected by the zoom. I
>> haven't
>> tested it in detail, but a rudimentary test shows different results.
>> However, that also suggests a workaround:
>>
>> Selection.RANGE.Information() is *not* (it appears, again on a quick
>> test)
>> affected by zoom.
>>
>>
>>
>>
>>
>>
>> "Charlie''s Word VBA questions"
>> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
>> news:2752C49F-210A-469B-BAB2-3F6B9198D62A[ at ]microsoft.com...
>> > Yes, I misread the Help. Thank you.
>> > I did some more experimenting with this. I would bet that in your
>> > test,
>> > the
>> > zoom was 100%. If you change the zoom to, say, 90%, the number of
>> > points
>> > will be 18.45 in the paragraph is indented .25 inches.
>> >
>> > "Jezebel" wrote:
>> >
>> >> You've misread the Help file. Information() returns points, not twips
>> >> ...
>> >>
>> >> wdHorizontalPositionRelativeToPage Returns the horizontal position of
>> >> the
>> >> specified selection or range; this is the distance from the left edge
>> >> of
>> >> the
>> >> selection or range to the left edge of the page measured in points (1
>> >> point
>> >> = 20 twips, 72 points = 1 inch). If the selection or range isn't
>> >> within
>> >> the
>> >> screen area, returns - 1.
>> >>
>> >> wdVerticalPositionRelativeToPage Returns the vertical position of the
>> >> selection or range; this is the distance from the top edge of the
>> >> selection
>> >> to the top edge of the page measured in points (1 point = 20 twips, 72
>> >> points = 1 inch). If the selection isn't visible in the document
>> >> window,
>> >> returns - 1.
>> >>
>> >>
>> >> Separately, I think there must be something interfering with your
>> >> positioning, rather than internal conversion problems. I normally work
>> >> in
>> >> millimetres (so these measurements are never exact); but I just tried
>> >> changing to inches and setting the margin to 0.25 inches.
>> >> selection.Information(wdHorizontalPositionRelativeToPage) returns
>> >> exactly
>> >> 18, as expected.
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> "Charlie''s Word VBA questions"
>> >> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
>> >> news:5B984BAC-ADE3-4467-B97B-FEF51711A4C0[ at ]microsoft.com...
>> >> > In a macro, the value returned by
>> >> > "Selection.Information(wdHorizontalPosition..." and
>> >> > "Selection.Information(wdVerticalPosition...)" is in points, even
>> >> > though
>> >> > the
>> >> > help says the value is in twips. I assume that the function is
>> >> > accurate.
>> >> > Should the returned value be rounded or truncated or used exactly as
>> >> > returned? For example, if a paragraph is indented 0.5 inches, the
>> >> > returned
>> >> > value is 36.0 points which computes to an actual indent of 0.5
>> >> > inches.
>> >> > However, if the paragraph is indented 0.25 inches, the returned
>> >> > value
>> >> > is
>> >> > 18.45 points which computes to exactly 0.25625 inches.
>> >> > Can Word actually do its metrics in fractions of points and, for
>> >> > that
>> >> > matter, in fractions of twips? When returned values are converted
>> >> > to
>> >> > twips,
>> >> > occassionally the answer is in fractions of twips. I have double-
>> >> > and
>> >> > triple-checked the calculations and for multiples of 1/2 inch (0.0,
>> >> > 0.5,
>> >> > 1.0,
>> >> > etc.), the results are always perfect.
>> >> > Thanks for your help.
>> >>
>> >>
>> >>
>>
>>
>>


Re: Points returned by Information(wdHorizontalPosition...)
Adri Rietjens 12/31/2008 2:17:00 AM
I'm having problems using
selection.information(wdVerticalPositionRelativeToPage) too. I'm using Word
2003.
Zoom is correct. Pagelayout is active. But still.
It fails when the paragraph has been formatted with 'Space before'. Only the
first line returns a correct value for
selection.information(wdVerticalPositionRelativeToPage). The second and
following lines of the paragraph return incorrect values. I use the values to
draw a horizontal line straight behind the last character of that textline.
What am I doing wrong?


"Jezebel" wrote:

[Quoted Text]
> You'd do better learning to use Range objects. Almost all code runs quicker
> and more reliably.
>
>
>
>
> "Charlie''s Word VBA questions"
> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
> news:FF17A75F-7353-438B-B236-8969ABCD6422[ at ]microsoft.com...
> > Thank you. I had a problem with using Range, perhaps because I didn't use
> > it
> > in all places I needed to. The macro I have gets the distance from the
> > paper
> > left, the left margin, top of page, from top margin, from right margin,
> > etc.
> > My macro executes nearly instantly, so I have used the following code. I
> > also use this method in other macros to get the user's settings, then
> > restore
> > them when the macro ends.
> > 'Zoom percent
> > CurrZoom = ActiveDocument.ActiveWindow.View.Zoom
> > ActiveDocument.ActiveWindow.View.Zoom = 100
> > ---------
> > 'Restore Zoom
> > ActiveDocument.ActiveWindow.View.Zoom = CurrZoom
> >
> >
> > "Jezebel" wrote:
> >
> >> You're right that Selection.Information() is affected by the zoom. I
> >> haven't
> >> tested it in detail, but a rudimentary test shows different results.
> >> However, that also suggests a workaround:
> >>
> >> Selection.RANGE.Information() is *not* (it appears, again on a quick
> >> test)
> >> affected by zoom.
> >>
> >>
> >>
> >>
> >>
> >>
> >> "Charlie''s Word VBA questions"
> >> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
> >> news:2752C49F-210A-469B-BAB2-3F6B9198D62A[ at ]microsoft.com...
> >> > Yes, I misread the Help. Thank you.
> >> > I did some more experimenting with this. I would bet that in your
> >> > test,
> >> > the
> >> > zoom was 100%. If you change the zoom to, say, 90%, the number of
> >> > points
> >> > will be 18.45 in the paragraph is indented .25 inches.
> >> >
> >> > "Jezebel" wrote:
> >> >
> >> >> You've misread the Help file. Information() returns points, not twips
> >> >> ...
> >> >>
> >> >> wdHorizontalPositionRelativeToPage Returns the horizontal position of
> >> >> the
> >> >> specified selection or range; this is the distance from the left edge
> >> >> of
> >> >> the
> >> >> selection or range to the left edge of the page measured in points (1
> >> >> point
> >> >> = 20 twips, 72 points = 1 inch). If the selection or range isn't
> >> >> within
> >> >> the
> >> >> screen area, returns - 1.
> >> >>
> >> >> wdVerticalPositionRelativeToPage Returns the vertical position of the
> >> >> selection or range; this is the distance from the top edge of the
> >> >> selection
> >> >> to the top edge of the page measured in points (1 point = 20 twips, 72
> >> >> points = 1 inch). If the selection isn't visible in the document
> >> >> window,
> >> >> returns - 1.
> >> >>
> >> >>
> >> >> Separately, I think there must be something interfering with your
> >> >> positioning, rather than internal conversion problems. I normally work
> >> >> in
> >> >> millimetres (so these measurements are never exact); but I just tried
> >> >> changing to inches and setting the margin to 0.25 inches.
> >> >> selection.Information(wdHorizontalPositionRelativeToPage) returns
> >> >> exactly
> >> >> 18, as expected.
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> "Charlie''s Word VBA questions"
> >> >> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
> >> >> news:5B984BAC-ADE3-4467-B97B-FEF51711A4C0[ at ]microsoft.com...
> >> >> > In a macro, the value returned by
> >> >> > "Selection.Information(wdHorizontalPosition..." and
> >> >> > "Selection.Information(wdVerticalPosition...)" is in points, even
> >> >> > though
> >> >> > the
> >> >> > help says the value is in twips. I assume that the function is
> >> >> > accurate.
> >> >> > Should the returned value be rounded or truncated or used exactly as
> >> >> > returned? For example, if a paragraph is indented 0.5 inches, the
> >> >> > returned
> >> >> > value is 36.0 points which computes to an actual indent of 0.5
> >> >> > inches.
> >> >> > However, if the paragraph is indented 0.25 inches, the returned
> >> >> > value
> >> >> > is
> >> >> > 18.45 points which computes to exactly 0.25625 inches.
> >> >> > Can Word actually do its metrics in fractions of points and, for
> >> >> > that
> >> >> > matter, in fractions of twips? When returned values are converted
> >> >> > to
> >> >> > twips,
> >> >> > occassionally the answer is in fractions of twips. I have double-
> >> >> > and
> >> >> > triple-checked the calculations and for multiples of 1/2 inch (0.0,
> >> >> > 0.5,
> >> >> > 1.0,
> >> >> > etc.), the results are always perfect.
> >> >> > Thanks for your help.
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Re: Points returned by Information(wdHorizontalPosition...)
"Jonathan West" <jwest[ at ]mvps.org> 12/31/2008 10:58:12 AM

"Adri Rietjens" <Adri Rietjens[ at ]discussions.microsoft.com> wrote in message
news:8EBF9A96-66D8-47F0-8EAE-6D813A101180[ at ]microsoft.com...
[Quoted Text]
> I'm having problems using
> selection.information(wdVerticalPositionRelativeToPage) too. I'm using
> Word
> 2003.
> Zoom is correct. Pagelayout is active. But still.
> It fails when the paragraph has been formatted with 'Space before'. Only
> the
> first line returns a correct value for
> selection.information(wdVerticalPositionRelativeToPage). The second and
> following lines of the paragraph return incorrect values. I use the values
> to
> draw a horizontal line straight behind the last character of that
> textline.
> What am I doing wrong?
>

Imagine the range is actually selected and highlighted. The
wdVerticalPositionRelativeToPage value returns the position of the top of
the selection. In the first line of a paragraph with Space Before set, in
order to get the position of the top of the actual text, you need to add the
SpaceBefore value to the wdVerticalPositionRelativeToPage value.

However, it can get a bit more complex still. In the Tools Options
Compatibility dialog, if you have the "Don't use HTML paragraph spacing" box
unchecked, and your paragraphs have both Space Before and Space After set to
some value greater than zero, then the interparagraph spacing isn't the sum
of the Space After of the paragraph above and the Space Before of the
paragraph below. Instead, the inter-paragraph spacing is whichever is larger
of the two.

Now, this affects how much additional space above the first line of a
paragraph is "selected". Extra space above the first line is only selected
if the Space Before is greater than the Space After, and the amount selected
is equal to the difference in that case.

Your calculations using wdVerticalPositionRelativeToPage have to take these
issues into account.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup


Re: Points returned by Information(wdHorizontalPosition...)
Charlie''s Word VBA questions 12/31/2008 11:39:03 AM
I have not tried to account for each line in a paragraph. However, can you
determine the amount of "space before" and add that to the value? Or, can
you go just add the distance from line to line based on the font size and
line spacing and add that to the value of the first line? (I am not sure if
you are trying to add a line after only the last line or each line in the
paragraph.)

"Adri Rietjens" wrote:

[Quoted Text]
> I'm having problems using
> selection.information(wdVerticalPositionRelativeToPage) too. I'm using Word
> 2003.
> Zoom is correct. Pagelayout is active. But still.
> It fails when the paragraph has been formatted with 'Space before'. Only the
> first line returns a correct value for
> selection.information(wdVerticalPositionRelativeToPage). The second and
> following lines of the paragraph return incorrect values. I use the values to
> draw a horizontal line straight behind the last character of that textline.
> What am I doing wrong?
>
>
> "Jezebel" wrote:
>
> > You'd do better learning to use Range objects. Almost all code runs quicker
> > and more reliably.
> >
> >
> >
> >
> > "Charlie''s Word VBA questions"
> > <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
> > news:FF17A75F-7353-438B-B236-8969ABCD6422[ at ]microsoft.com...
> > > Thank you. I had a problem with using Range, perhaps because I didn't use
> > > it
> > > in all places I needed to. The macro I have gets the distance from the
> > > paper
> > > left, the left margin, top of page, from top margin, from right margin,
> > > etc.
> > > My macro executes nearly instantly, so I have used the following code. I
> > > also use this method in other macros to get the user's settings, then
> > > restore
> > > them when the macro ends.
> > > 'Zoom percent
> > > CurrZoom = ActiveDocument.ActiveWindow.View.Zoom
> > > ActiveDocument.ActiveWindow.View.Zoom = 100
> > > ---------
> > > 'Restore Zoom
> > > ActiveDocument.ActiveWindow.View.Zoom = CurrZoom
> > >
> > >
> > > "Jezebel" wrote:
> > >
> > >> You're right that Selection.Information() is affected by the zoom. I
> > >> haven't
> > >> tested it in detail, but a rudimentary test shows different results.
> > >> However, that also suggests a workaround:
> > >>
> > >> Selection.RANGE.Information() is *not* (it appears, again on a quick
> > >> test)
> > >> affected by zoom.
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> "Charlie''s Word VBA questions"
> > >> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
> > >> news:2752C49F-210A-469B-BAB2-3F6B9198D62A[ at ]microsoft.com...
> > >> > Yes, I misread the Help. Thank you.
> > >> > I did some more experimenting with this. I would bet that in your
> > >> > test,
> > >> > the
> > >> > zoom was 100%. If you change the zoom to, say, 90%, the number of
> > >> > points
> > >> > will be 18.45 in the paragraph is indented .25 inches.
> > >> >
> > >> > "Jezebel" wrote:
> > >> >
> > >> >> You've misread the Help file. Information() returns points, not twips
> > >> >> ...
> > >> >>
> > >> >> wdHorizontalPositionRelativeToPage Returns the horizontal position of
> > >> >> the
> > >> >> specified selection or range; this is the distance from the left edge
> > >> >> of
> > >> >> the
> > >> >> selection or range to the left edge of the page measured in points (1
> > >> >> point
> > >> >> = 20 twips, 72 points = 1 inch). If the selection or range isn't
> > >> >> within
> > >> >> the
> > >> >> screen area, returns - 1.
> > >> >>
> > >> >> wdVerticalPositionRelativeToPage Returns the vertical position of the
> > >> >> selection or range; this is the distance from the top edge of the
> > >> >> selection
> > >> >> to the top edge of the page measured in points (1 point = 20 twips, 72
> > >> >> points = 1 inch). If the selection isn't visible in the document
> > >> >> window,
> > >> >> returns - 1.
> > >> >>
> > >> >>
> > >> >> Separately, I think there must be something interfering with your
> > >> >> positioning, rather than internal conversion problems. I normally work
> > >> >> in
> > >> >> millimetres (so these measurements are never exact); but I just tried
> > >> >> changing to inches and setting the margin to 0.25 inches.
> > >> >> selection.Information(wdHorizontalPositionRelativeToPage) returns
> > >> >> exactly
> > >> >> 18, as expected.
> > >> >>
> > >> >>
> > >> >>
> > >> >>
> > >> >>
> > >> >> "Charlie''s Word VBA questions"
> > >> >> <CharliesWordVBAquestions[ at ]discussions.microsoft.com> wrote in message
> > >> >> news:5B984BAC-ADE3-4467-B97B-FEF51711A4C0[ at ]microsoft.com...
> > >> >> > In a macro, the value returned by
> > >> >> > "Selection.Information(wdHorizontalPosition..." and
> > >> >> > "Selection.Information(wdVerticalPosition...)" is in points, even
> > >> >> > though
> > >> >> > the
> > >> >> > help says the value is in twips. I assume that the function is
> > >> >> > accurate.
> > >> >> > Should the returned value be rounded or truncated or used exactly as
> > >> >> > returned? For example, if a paragraph is indented 0.5 inches, the
> > >> >> > returned
> > >> >> > value is 36.0 points which computes to an actual indent of 0.5
> > >> >> > inches.
> > >> >> > However, if the paragraph is indented 0.25 inches, the returned
> > >> >> > value
> > >> >> > is
> > >> >> > 18.45 points which computes to exactly 0.25625 inches.
> > >> >> > Can Word actually do its metrics in fractions of points and, for
> > >> >> > that
> > >> >> > matter, in fractions of twips? When returned values are converted
> > >> >> > to
> > >> >> > twips,
> > >> >> > occassionally the answer is in fractions of twips. I have double-
> > >> >> > and
> > >> >> > triple-checked the calculations and for multiples of 1/2 inch (0.0,
> > >> >> > 0.5,
> > >> >> > 1.0,
> > >> >> > etc.), the results are always perfect.
> > >> >> > Thanks for your help.
> > >> >>
> > >> >>
> > >> >>
> > >>
> > >>
> > >>
> >
> >
> >

Home | Search | Terms | Imprint
Newsgroups Reader