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

    Search for Cell indicator (97SR2)

    Is it possible to use the .find method to find the table cell indicator, which looks like the grayed out square in a cell and is really a chr(13)&chr(7) ??
    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
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Search for Cell indicator (97SR2)

    That doesn't work for me. Even if I type Alt-0007 to insert that character I cannot find it.

    Can you use something like this?

    <pre>Sub FindCellEnds()
    Dim aTable As Table, lngRow As Long, lngCol As Long
    Dim rngCellEnd As Range
    For Each aTable In ActiveDocument.Tables
    For lngRow = 1 To aTable.Rows.Count
    For lngCol = 1 To aTable.Columns.Count
    Set rngCellEnd = ActiveDocument.Range( _
    aTable.Cell(lngRow, lngCol).Range.End - 1, _
    aTable.Cell(lngRow, lngCol).Range.End - 1)
    'next two lines for testing only
    rngCellEnd.Select
    MsgBox "Row " & lngRow & ", Column " & lngCol & vbCrLf & _
    "Start Position " & rngCellEnd.Start & _
    ", End Position " & rngCellEnd.End
    Next
    Next
    Next
    End Sub</pre>

    If you're in the cell, it's simpler:
    <pre>Sub FindSelectedCellEnd()
    Dim rngCellEnd As Range
    Set rngCellEnd = ActiveDocument.Range(Selection.Cells(1).Range.End - 1, _
    Selection.Cells(1).Range.End - 1)
    'next two lines for testing only
    rngCellEnd.Select
    MsgBox "Start Position " & rngCellEnd.Start & _
    ", End Position " & rngCellEnd.End
    End Sub</pre>


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

    Re: Search for Cell indicator (97SR2)

    What I need is a way to search for text in a document that may be in a table cell. I need to be able to search for the text and the NEXT character (which in the case of a cell is chr(13) followed by chr(7). But adding that chr(13) to the search returns nothing. In other words, .find thinks chr(13) is the paragraph mark, not the 1st of two chars in the end of cell mark. Oh, boy..
    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>

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Search for Cell indicator (97SR2)

    I don't think you can do it as a single step. If you search for the text and then test for its adjacency to the end-of-cell marker, is that good enough? Assuming you are using a selection.find object, something like:

    ...
    While .Execute() <> False Then
    If Selection.Information(wdWithInTable) = True Then
    If Selection.Range.End = _
    (Selection.Cells(1).Range.End - 1) Then
    MsgBox "You Got a Match at the End of a Cell!"
    Else
    MsgBox "You Got a Match in a Table Not at the End of a Cell!"
    End If
    Else
    MsgBox "You Got a Match Not in a Table!"
    End If
    Wend

  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: Search for Cell indicator (97SR2)

    Jefferson,

    I like this. I have not applied it to my code yet, but it looks very promising. Thanks very much. I'll post back after testing. <img src=/S/ribbon.gif border=0 alt=ribbon width=15 height=15>
    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>

Posting Permissions

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