locked
Help with Microsoft Word 2003 table macros RRS feed

  • Question

  •      I have a word template *.doc file that I am using to automate trip reports.  I have a hard coded list of "known" contacts that I am populating to a word table, in this case table(5).  The part that I am having complications with is making the table rows dynamic to the number of selected contacts.  For example, the current list of contacts is 24 people, so I have 26 rows in my template.  I would like this to auto adjust to the number of selected contacts, so that the table starts with 2 rows (a header and an empty) and automatically adds a row for each contact selected.  Any suggestions for how to do this would be greatly appreciated.
    Very Respectfully,
    Robert McCaulley
    Monday, February 23, 2009 6:19 PM

All replies

  • Here is a hint that you can customize:

    Sub AddRows2Table()  
     
    Dim oTable As Table  
    Dim iSelContacts As Integer 
    Dim iRowsToBeAdded As Integer 
    Dim i1 As Integer 
     
    Set oTable = ActiveDocument.Tables(1)  
     
    iRowsToBeAdded = iSelContacts + 2  
     
    For i1 = 1 To iRowsToBeAdded  
        oTable.Rows.Add  
    Next i1  
    End Sub 

    Cheers
    Shasur
    http://www.vbadud.blogspot.com
    Tuesday, February 24, 2009 6:18 AM