Inserting a page at the end of a document

T

triaz

Hi,

I have some values held in an array (this is a dynamic array and the
size of this changes constantly) what I need is to:
insert a page at the end of a document (the document size varies).
create a table on this page (5 columns, rows variable as array is dynamic)
using values held in the dynamic array I need to add them to the table, rows being created
automatically when required

Can anyone help.

Thanks in advance

Regards

T.
 
J

Jezebel

It would be easier to help if you explained your actual problem and what you
need help with. What have you tried so far, and where did you get stuck?
 
S

scottw

Hi Triaz,

I think this will do:
Set ad = ActiveDocument
ad.Tables.Add ad.Bookmarks("\endofdoc").Range, UBound(myArray) + 1, 5

'Here is a longer, one row at a time, version:
Sub LongerWay(myDynamicArray As Variant)
Dim rowNum As Long, myTable As Table, val As Variant
Set myTable =
ActiveDocument.Tables.Add(ActiveDocument.Bookmarks("\endofdoc").Range, 1, 5)
For Each val In myDynamicArray
rowNum = rowNum + 1
If rowNum > 1 Then myTable.rows.Add
For colNum = 1 To 5 'put something in each cell
myTable.Cell(rowNum, colNum).Range = rowNum & ": " & colNum
Next colNum
Next val
End Sub

'Use it like this:
'LongerWay array(1,2,3)

Enjoy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top