Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Go To bypasses tables (Word 2002)

    Can anyone tell me why the Edit Go To Line command seems to bypass tables, and if there's any way around this?

    With the attached file, for example, if you put the cursor at the start of the document and enter 8 or +8 as the line number, you're taken to what - according to the Status bar - is line 13. And even if you're already in the table, Word jumps out of it to do its business.

    While I can manually go to the "correct" line, I had planned to incorporate this as part of a VBA routine to go to a designated page and line.
    Attached Files Attached Files

  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: Go To bypasses tables (Word 2002)

    That's odd. Word seems to treat each table row as a single line for purposes of GoTo line. What exactly are you trying to do with this approach? There almost certainly is another way.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Go To bypasses tables (Word 2002)

    What we do here is periodically search 700+ Word documents and identify words or phrases. These are identified according to their location - on page 10, line 3 (for example). If the text found is in a table, VBA can correctly identify the line using Selection.Information(wdFirstCharacterLineNumber). What happens afterwards, however, is that some users try to go to each location using GoTo and the Page and Line options, and - presuming they remember to make the line references relative - still curse every time a table gets bypassed and they end up in the wrong location.

    To help the particularly grumpy types, I tried building a form in which users enter page and line numbers - but my attempt using "Selection.GoTo What:=wdGoToLine, Which:=wdGoToRelative, Count:=vntGoToLineNumber" to go to the designated line still bypasses a table.

    I suppose we could amend the original report to create hyperlinks to the locations in the other documents, but some users insist on working from a hard copy and our initial approach is to try and accommodate them as much as possible.

  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: Go To bypasses tables (Word 2002)

    You could use Selection.MoveDown to position on the line. Here's a rather simplistic example that could use a better UI:

    <code>Sub GotoPageLine()
    Dim strPageLine As String, lngPage As Long, lngLine As Long
    Do
    strPageLine = InputBox("Enter page and line in the format shown" & _
    " (leave blank to cancel)", "Go to Spot", "1:20")
    If Len(Trim(strPageLine)) = 0 Then Exit Sub
    If InStr(1, strPageLine, ":") < 2 Then
    MsgBox "Please try that again!", vbCritical + vbOKOnly
    ElseIf IsNumeric(Split(strPageLine, ":")(0)) And _
    IsNumeric(Split(strPageLine, ":")(1)) Then
    lngPage = CLng(Split(strPageLine, ":")(0))
    lngLine = CLng(Split(strPageLine, ":")(1))
    Exit Do
    Else
    MsgBox "Please try that again!", vbCritical + vbOKOnly
    End If
    Loop
    Selection.GoTo what:=wdGoToPage, which:=wdGoToAbsolute, Count:=lngPage
    If lngLine > 1 Then
    Selection.MoveDown unit:=wdLine, Count:=lngLine - 1
    End If
    End Sub</code>

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Go To bypasses tables (Word 2002)

    That works. Thanks. (Now why did I not think of it <img src=/S/bash.gif border=0 alt=bash width=35 height=39>.)

Posting Permissions

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