Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Top of Doc Test (97SR2)

    I'm drawing a blank **

    How do I test to see if the IP is that the top of the document?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    I'm thinking in posts...

    Is this right?

    If Selection.Start = 0 then
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Top of Doc Test (97SR2)

    Kevin

    There used to be a WordBasic Command that would tell you this but I can't remember it. I don't know a simple method anymore so I would do it with a kludge such as
    <pre>Sub temp1()
    Selection.Collapse Direction:=wdCollapseStart
    Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
    If Selection.Type = wdSelectionIP Then
    MsgBox "It's at the start"
    Else
    MsgBox "It's not at the start"
    End If
    End Sub</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    I had thought of a simpler

    [pre]
    if range.start = 0 then
    ' at top of document

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    The range property requires an object like "activedocument".

    So, range.start = 0 means nothing. You have to use Activedocument.Range.Start = 0, which is not as simple as

    selection.start = 0
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    Andrew,

    That's pretty clever: extend the selection from wherever it is currently to the top of the document and test to see if the selection is just the IP. If it is, you must be at the top because nothing but the IP would be selected.

    I'm still wondering about

    if selection.start = 0

    Seems to work, even if the selection type is not IP; but I'm not sure why. Any insights?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    > requires an object like "activedocument".

    Right.

    I should have said that I was using pseudocode (or "pseudocode" as we say in Australia).


    > not as simple as

    So? Who cares about simple if it's in a procedure? It's the difference between Selection. and ActiveDocument., correct? Presumably one would write the boolean-returning procedure to operate on a range. That's why I used range. Should've written .Range. etc. (mutter mutter mutter)

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    > selection type is not IP

    Does this mean "Selection type is not Insertion Point"? If so, what is it if it's not?




    > if selection.start = 0

    Isn't the start of a selection always going to be zero? And the .End of it the length of the selection? Am I more confused than ever?

    (signed) "curious" of Toronto.

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    Dear Curious,

    Your buttinsky sister in law has too much time on her hands... er., oh, sorry, wrong letter.

    Let's see. Woodys' Lounge, VBA forum, Chris G. Ah, yes.

    If the selection object type is not insertion point it could be any of the following types:

    wdNoSelection, wdSelectionBlock, wdSelectionColumn,
    wdSelectionFrame, wdSelectionInlineShape, wdSelectionIP,
    wdSelectionNormal, wdSelectionRow, or wdSelectionShape
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    > Let's see. Woodys' Lounge, VBA forum, Chris G. Ah, yes.

    At least you lknow I've descended from the trees!


    >wdNoSelection, wdSelectionBlock, wdSelectionColumn,
    wdSelectionFrame, wdSelectionInlineShape, wdSelectionIP,
    wdSelectionNormal, wdSelectionRow, or wdSelectionShape

    So presumably you first test to see if it is a "wdSelectionIP", and then test the .start point?


    By now I'm a tad confused. If I want to know if any thing (that has a range) is at the start of a document, I'd just have tested thing.Range.Start =0.

    Are we disagreeing on that?

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    I put IP in a paragraph somewhere and type in IM window

    ?activedocument.range.start

    Returns 0 (zero)

    Now press Ctrl-Home putting IP at top of doc. Again

    ?activedocument.range.start

    Returns 0 again. This test does not seem to work. It returns 0 no matter where the IP is.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    Snap quiz: What's the .Range of an object affectionately known as "ActiveDocument"?

    (can you slap your forehead yourself, or do you want me to do it online?).



    Next quiz: Will that range be the same for any ActiveDocument on any version of Word(97 and up).


    hah hah hah hah gotcha!

  13. #13
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    Don't hurt me. Go ahead and slap... <img src=/S/bash.gif border=0 alt=bash width=35 height=39>
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  14. #14
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    Right, but you do see why it's always =0 don't you?

  15. #15
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Top of Doc Test (97SR2)

    Yeah. The activedoc "range" always starts at 0. Activedocument.Range.End will always be the number of chars (including all "codes") in the doc.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •