Oddities:wdVerticalPositionRelativeToTextBoundary

G

George Lee

Has anyone experienced problems with wdVerticalPositionRelativeToTextBoundary?

In my case, the return value is always zero. In the following code, the last
two calls return correct values. The first two are always zero, regardless
where the cursor is.

Dim x As Double
x =
gTargetDoc.Application.Selection.Range.Information(wdVerticalPositionRelativeToTextBoundary)
x =
gTargetDoc.Application.Selection.Range.Information(wdHorizontalPositionRelativeToTextBoundary)

x =
gTargetDoc.Application.Selection.Range.Information(wdHorizontalPositionRelativeToPage)
x =
gTargetDoc.Application.Selection.Range.Information(wdVerticalPositionRelativeToTextBoundary)
 
J

Jean-Guy Marcil

George Lee was telling us:
George Lee nous racontait que :
Has anyone experienced problems with
wdVerticalPositionRelativeToTextBoundary?

In my case, the return value is always zero. In the following code,
the last two calls return correct values. The first two are always
zero, regardless where the cursor is.

Dim x As Double
x =
gTargetDoc.Application.Selection.Range.Information(wdVerticalPositionRelativeToTextBoundary)
x =
gTargetDoc.Application.Selection.Range.Information(wdHorizontalPositionRelativeToTextBoundary)

x =
gTargetDoc.Application.Selection.Range.Information(wdHorizontalPositionRelativeToPage)
x =
gTargetDoc.Application.Selection.Range.Information(wdVerticalPositionRelativeToTextBoundary)

This is because TextBoundary is generally used when the selection is within
a frame, a cell or textbox.
 
G

George Lee

Thanks. However that doesn't explain it in this case. It's the same code,
same files but different Office versions. The more general problem is that
this code worked fine with Office 2003 and not for Office 2007. I ended up
changing the code to:
gTargetDoc.Application.Selection.Information(wdVerticalPositionRelativeToTextBoundary)

which seems to work fine now but not for Office 2003, which we still have to
support. I don't want a duel code base and there is nothing in the
documentation or even from Google searches to confirm this. There seems to be
a lot of subtle differences. Can you comment on that?
 
J

Jean-Guy Marcil

George Lee was telling us:
George Lee nous racontait que :
Thanks. However that doesn't explain it in this case. It's the same
code, same files but different Office versions. The more general
problem is that this code worked fine with Office 2003 and not for
Office 2007. I ended up changing the code to:
gTargetDoc.Application.Selection.Information(wdVerticalPositionRelativeToTextBoundary)

which seems to work fine now but not for Office 2003, which we still
have to support. I don't want a duel code base and there is nothing
in the documentation or even from Google searches to confirm this.
There seems to be a lot of subtle differences. Can you comment on
that?

It seems to me that TextBoundary will not work properly if the cursor is not
in a frame, a table, or a textbox when you are in 2003, however, in 2007,
the TextBoundary seems to be the margins, if the cursor is not in a table,
frame, etc..

However, RelativeToPage returns the same values in both version, so why
don't you use RelativeToPage?
 

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