tables

Hi,

I'm trying to write a few procedures in VBA concerning tables -
is there any way of accessing the text contained in the tables without actually having to select it in the document

akso, is there way through which I can detect where I am in a table, i.e if the cursor is in cell (2,3) is there any way of detecting this

same about foot/end notes - Is there any way of finding out which footnote I am editting (for instance, if I should want to make a list of end note numbers which containinf a certain string).


Thanks.


Answer this question

tables

  • hanayoub

    Thanks for your reply,

    I'm using VBA for word -

    I'm doing several projects, one of them being to transfer an index from table format to list format, in order to do so it is neccessary to go through the entire table and process it, reformatting it. The method I used was by reading the entire table as a text variable and creating a procedure which transferred it to a matrix (two dimensional array) using chr(13) and chr(7) to detect new columns & rows. Is there not a better way of accessing the table data directly without doing the above


    As for detecting where I am in a table / endnotes, in a book I was editting, any problems were marked as style "problems" - and I was trying to generate a report of which pages, and in which comments this style appeared. However, although it was easy to detect where they appeared, I had no way of knowing where I was in the endnotes. To overcome this problem I wrote a procedure typing over the endnote references with text, and then going to the beginning of the paragraph, thereby finding at which endnote number I actually am - again a very clumsy method.


    Summary of problems:
    1. Accessing data in word files without having to make word go into every cell and check its contents, but rather direct access on programming level.
    2. Discovering where the cursor is in a table (which row, column), endnote (what number)

    thanks again and sorry about the length.

  • israeliteknight

    Per one of our support engineers:

    Please find answers below to the partner’s two questions.< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    1. Accessing data in word files without having to make word go into every cell and check its contents, but rather direct access on programming level.

    2. Discovering where the cursor is in a table (which row, column), endnote (what number)

    I suppose Q1 is just similar to a part of Q2, please confirm it from the partner.

    Please refer to following code to detect the exact cell the cursor in.

    Sub TestCode()

        Dim col As Integer

        Dim row As Integer

       

        If GetCellIndex(selection, col, row) Then

            MsgBox "Row: " & row & " Col: " & col

        Else

            MsgBox "Selection is not in Table"

        End If

    End Sub

     

    Function GetCellIndex(ByVal selRange As selection, ByRef colIdx As Integer, ByRef rowIdx As Integer) As Boolean

     

       On Error GoTo ErrorHandler: 'In case there's no cell object

       colIdx = selRange.Cells(1).ColumnIndex

       rowIdx = selRange.Cells(1).RowIndex

      

       GetCellIndex = True

      

       Exit Function

     

    ErrorHandler:

       colIdx = -1

       rowIdx = -1

       GetCellIndex = False

    End Function

     

    For endernote, I think our buddy has some misunderstanding. An endnote is to tell the end-user “here is a mark”, instead of “it’s a mark for this (these) word(s)”. We can jump to the location where there’s a endnote by following code:

     

    Sub EndNote()

     

        If ActiveWindow.ActivePane.View.Type = wdPrintView Or ActiveWindow. _

            ActivePane.View.Type = wdWebView Or ActiveWindow.ActivePane.View.Type = _

            wdPrintPreview Then

            ActiveWindow.View.SeekView = wdSeekMainDocument

        Else

            ActiveWindow.Panes(1).Close

        End If

       

    End Sub

     

    Anything unclear, Kindly let me know the details as soon as possible.

    The engineer also has a .doc attachment to share with you in case you're interested. I'm unableto attach the file to this post, so if you'd like to see it please email me at budsup@microsoft.com.
    Hope this helps!
    -brenda (ISV Buddy Team)



  • Jirka1

    we've escalated your question to one of our support engineers, who needs some additional clarification to properly answer your question(s):

    You want to select certain text contents that the Excel table has got without actually selecting it What are you trying to achieve here, is the purpose just to find a given text Can you give more details

    Are you using Excel/Word/Access VBA programming and can you provide any sample code of what you are trying to achieve

    please post your answers here and I'll make sure that the information gets back to the engineer.

    thanks,
    -brenda (ISV Buddy Team)



  • tables