Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    May 2002
    Location
    London, Gtr London, England
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    selecting across cells in a table (2000 9.0.4402/SR1)

    Hi I'm trying to detect the symbol just in front of a selection ( I'm looking for the decimal point) and all is well unless I'm in a table.
    If I have 2 cells and the second holds a number ( no spaces) and I select the number and then move the start of the selection to the left ( count = -1) then sure enough the previous cell is selected as well. So I detect this and try to move the selection back but it won't let me. Try the following code to see what I mean

    Set up 2 cells Put 1234 in the second 1 and what you like in the first. Select the number in the second cell and run the code. The selection stays the same.

    Selection.moveright is no help either as it moves the right hand end of the selection.

    Baffled
    Any thoughts?
    Richard

    ' extend start of selection to the left
    Selection.MoveStart Unit:=wdCharacter, Count:=-1
    ' detect cell marker
    If InStr(Selection, Chr$(11)) Or InStr(Selection, Chr$(13)) Or InStr(Selection, " ") Or InStr(Selection, Chr$(7)) Then
    ' move selection back where it was
    Selection.MoveStart Unit:=wdCharacter, Count:=1
    End If

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selecting across cells in a table (2000 9.0.4402/SR1)

    Hi Richard,

    The rule in tables is that the whole cell will be selected as long as the end-of-cell-marker is selected.

    You would have to move the start of the selection by the number of characters in the cell plus one (or use Selection.MoveStart Unit:=wdCell, Count:=1).

    But the easiest solution is not to change the Selection at all:
    MsgBox AscW(Selection.Characters.First.Previous)
    will show you the character to the left of the selection.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  3. #3
    New Lounger
    Join Date
    May 2002
    Location
    London, Gtr London, England
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selecting across cells in a table (2000 9.0.4402/SR1)

    Ta for that. I had not seen the First.Previous method before
    Richard

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: selecting across cells in a table (2000 9.0.4402/SR1)

    Actually, it seems a thing out of Alice's Wonderland (starting with a Collection like Selection.Characters, and then examining the .First.Previous item -- or .Last.Next.Next item <img src=/S/brainwash.gif border=0 alt=brainwash width=15 height=15>). But as long as it works...

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

Posting Permissions

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