Results 1 to 3 of 3

Thread: Creating multiple tables

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Creating multiple tables

    Hello,

    I'm trying to mash together some code to speed along a process of making certain types of documents. Basically I have a form where I fill out all the information I need, press a generate button, and it's transfered to the word document in a certain format. Type in another set of information, press generate, and another table is placed underneath the first one. And so on...

    I have the code:

    [VBA]Set tableNew = ThisDocument.Tables.Add(Selection.Range, X, Y)
    With tableNew
    .Rows(1).Shading.BackgroundPatternColor = wdColorGray125
    .Cell(1, 1).Range.InsertAfter "Conveyor Section"
    .Cell(1, 2).Range.InsertAfter "Device Type"
    .Cell(1, 3).Range.InsertAfter "Device Sub-Type"
    .Cell(1, 4).Range.InsertAfter "Functional Description"
    .Cell(1, 5).Range.InsertAfter "P/F"
    .Cell(1, 6).Range.InsertAfter "Comments"
    .Cell(1, 7).Range.InsertAfter "Date"
    End With [/VBA]

    My question is: How do I create another table below the first one? Do I need to keep track of some kind of index number when I reference the 2nd, 3rd, etc table, or can I reference the cells like the code: put "this" in cell(1,1) for table 2?

    Many thanks for any help. I'm a PLC programmer, so feel free to roll your eyes at my (hopefully) silly questions
    Last edited by Killian; 04-29-2005 at 08:11 AM. Reason: Added VBA tags

Posting Permissions

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