Thankyou for your inputs.
In my code, I read and store all the fields (ie, hyperlinks ) within
the document. So at any time, I can call field.Select() to get the
selection.
As per your explanation, If I have code as below,
selection s = field.Select()
Range r = s.GetRange()
s.collapse(wdCollapseStart)
After this, I can call Selection.GetBookMarks() but it does not accept
any parameters. which method should I call to pass "\page"?
And how do I split a range object into two? Could you pls. explain.
Thanks.
I was thinking of another approach.
For ex. if I have a selection which starts on Page 1 and ends on Page
2.
- I get the original selection.
- I move the start position of selection by calling
Selection.MoveStart(wdCharacter, 1).
- I collapse the selection to start.
- Get the page# by Selection.Information(wdActiveEndPage..).
- Then, keep moving the start position, till I get to the next page#,
and then I stop.
I thought this approach ill reduce the selection by 1 character each
time I call MoveStart().
So if the original selection has the text, "This is an example",
MoveStart(),
s = GetSelection()
s.GetText();
will return, "his is an example" (without "T")
But this code does not seem to work.
Could you pls. tell if this approach is feasible? or any alternate ways
to do it?
Thanks.
ksr was telling us:
ksr nous racontait que :
> Thankyou for your inputs.
>
[quoted text clipped - 10 lines]
> After this, I can call Selection.GetBookMarks() but it does not accept
> any parameters. which method should I call to pass "\page"?
As you are writing in C++, I am afraid I cannot help you with that, this is
a VBA group after all ;-)
(GetBookMarks() is not part of the Word object library)
> And how do I split a range object into two? Could you pls. explain.
Declare two range variables (Range1 and Range2)
Set Range1 to the whole original range.
Set Range2 to start where Range1 starts and to finish somewhere in the
middle.
You now have two ranges where Range2 is a sub-range of Range1.
> Thanks.
>
[quoted text clipped - 25 lines]
> Could you pls. tell if this approach is feasible? or any alternate
> ways to do it?
I would store the Selection end point.
Collapse the selection to its beginning.
Move the end point until it is either on a different page or until you reach
the stored end point, whichever come first.
If the End point comes first, the whole selection is on the same page, if
not....
Set a range to this new selection.
Collapse to the end ( you should now be at the beginning of the next page)
Set a range to start form the current selection point to the previously
stored end point.
Again, because you are dealing with C++, you are going to figure out the
code by yourself!
Good luck.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
ksr - 12 Apr 2006 20:47 GMT
Thanks for your inputs.
I understood upto the point where I try to move the endpoint till I
reach a different page or the stored end point. But after that,
"Set a range to this new selection.
Collapse to the end ( you should now be at the beginning of the next
page)
Set a range to start form the current selection point to the
previously
stored end point."
"Set a range to this new selection.
- Are you saying, I should create a range, with the stored start point
and the new end point now.
"Collapse to the end ( you should now be at the beginning of the next
page) "
- Is it that since collapse end refers to the range is located after
ending paragraph point, it will now be at start of next page?
After this, how to set a range to start from current selection point to
previously stored end point.
Can you pls. give me some code snippets in VBA? I will try to find
equivalent c++ code.
Thankyou very much.
> ksr was telling us:
> ksr nous racontait que :
[quoted text clipped - 79 lines]
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
Jean-Guy Marcil - 12 Apr 2006 22:59 GMT
ksr was telling us:
ksr nous racontait que :
> Thanks for your inputs.
>
[quoted text clipped - 21 lines]
> Can you pls. give me some code snippets in VBA? I will try to find
> equivalent c++ code.
Try this in VBA:
Dim FullRange As Range
Dim RangePart1 As Range
Dim RangePart2 As Range
Dim FullRangeEndPoint As Long
Dim WeHaveTwoRanges As Boolean
WeHaveTwoRanges = False
'Set FullRange = Selection.Fields(1).Result
Set FullRange = Selection.Paragraphs(1).Range
FullRangeEndPoint = FullRange.End
Set RangePart1 = FullRange
With RangePart1
'Start and end not on same page then below is true
If .Characters(1).Information(wdActiveEndPageNumber) <> _
.Characters(.Characters.Count).Information(wdActiveEndPageNumber)
Then
.Collapse wdCollapseStart
.MoveEnd wdCharacter, 1
WeHaveTwoRanges = True
'true if next charcter on same page as last character in current
range
Do While .Next.Characters(1).Information(wdActiveEndPageNumber) = _
.Characters(.Characters.Count).Information(wdActiveEndPageNumber)
.MoveEnd wdCharacter, 1
Loop
Set RangePart2 = ActiveDocument.Range(RangePart1.End, _
FullRangeEndPoint)
End If
End With
If WeHaveTwoRanges Then
'use RangePart1 and RangePart2
RangePart1.Select
RangePart2.Select
Else
'Use FullRange
FullRange.Select
End If

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
ksr - 13 Apr 2006 01:09 GMT
Thanks for taking time to write the whole code.
I will try to find equivalent c++ code and will try to implement this.
hope it works!
> ksr was telling us:
> ksr nous racontait que :
[quoted text clipped - 75 lines]
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org