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

    table.ID (Word 2000)

    <pre>Sub test()
    With Selection.Tables(1)
    .ID = "harold"
    End With
    End Sub
    Sub test2()
    MsgBox Selection.Tables(1).ID
    End Sub
    </pre>

    works, but I can't see how an end-user would set/interrogate the table.ID.

    Any hints would be appreciated.

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: table.ID (Word 2000)

    Chris

    As an alternative could you bookmark the tables? That way you could get the table from the bookmark


    set tbl = ActiveDocument.Bookmarks("tblBookmark").Range.Tabl es(1)
    Jerry

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

    Re: table.ID (Word 2000)

    >could you bookmark the tables?
    Thanks Jezza. I could, but I don't want to. Nothing personal ....(grin)

    I'm rewriting an HTML-generator and was looking at ways to identify tables so that I could generate a table Id or a table Class.
    I toyed as a user using tbl.Autoformat, and then in the generator inspecting tbl.AutoFormatType and mapping the AutoFormatType value (1, 2, 3 etc) to a known html table class.
    Then I saw tbl.ID and contemplated using that, but there seems little end-user support for loading the value of a tbl.ID. A macro (button) would work, of course.

    I might use a combination - allow either a tbl.ID or tbl.AutoFormatType, with the .ID, if non-empty, taking precedence over the AutoFormatType.

    FWIW I have to run through much the same exercise for Lists and Images, html-generating a Class or Id from something the user has done to the list or image.

  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: table.ID (Word 2000)

    If users are meant to have some control over such things, I think you need to add a context-sensitive metadata interface. On a custom toolbar, have an Attributes button and populate a property-inspector-style userform on the fly based on the position of the insertion point when that button is clicked.

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

    Re: table.ID (Word 2000)

    >a context-sensitive metadata interface

    Jefferson, you've been spending too much time in Scuttlebutt(<post:=749,086>post 749,086</post:>) <img src=/S/thinks.gif border=0 alt=thinks width=15 height=15> Can't I just write a macro that pops up a GUI form based on the selection?

    I've done much as you suggested with a bit of preliminary code that checks the environs of the table (paragraph following and paragraph preceding) in case there is text suitable for an .ID, which obviates the need for the GUI form display in that context.

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: table.ID (Word 2000)

    Hi Chris,

    To retrieve the current Table ID you could use code like:
    Function CurrentTable() As Integer
    Dim i As Integer
    For i = 1 To ActiveDocument.Tables.Count
    If (Selection.Range.Start >= ActiveDocument.Tables(i).Range.Start) And _
    (Selection.Range.End<= ActiveDocument.Tables(i).Range.End) Then
    CurrentTable = i
    Exit For
    End If
    Next i
    End Function
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  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: table.ID (Word 2000)

    Thanks Paul.
    I'd forgotten to post my solution (ISP was wonky) the other night:<pre>Public Sub SetTableId()
    If Selection.Information(wdWithInTable) Then
    Dim strId As String
    strId = InputBox("SetTableId", "SetTableId", "Normal")
    If Len(strId) > 0 Then
    Selection.Tables(1).ID = strId
    Else
    End If
    Else
    End If
    End Sub
    Public Sub GetTableId()
    If Selection.Information(wdWithInTable) Then
    MsgBox Selection.Tables(1).ID
    Else
    End If
    End Sub</pre>


Posting Permissions

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