Adding new rows

The PDF Creator enables you to create secure PDF documents and to view, print and process existing PDF documents.
If you have any questions about the installation and usage of the PDF Creator please post them here.
Post Reply
Randal
Posts: 9
Joined: Mon Sep 22 2003

Adding new rows

Post by Randal »

Hi!

When I try to add new rows to an existing table(with data) the previous filled in data disappear.

Private Sub cmdInsertTable_Click()
With PDFcreator
' create a table object
.CreateObject acObjectTypeTable, "Table 1"
' position the table object
.ObjectAttribute("Table 1", "Left") = 100
.ObjectAttribute("Table 1", "Top") = 1000
.ObjectAttribute("Table 1", "Right") = 3600
.ObjectAttribute("Table 1", "Bottom") = 2800
.ObjectAttribute("Table 1", "Rows") = 2
.ObjectAttribute("Table 1", "Columns") = 2
.ObjectAttribute("Table 1.Cells[1,1]", "Text") = "Text 1,1"
.ObjectAttribute("Table 1.Cells[1,2]", "Text") = "Text 1,2"
.ObjectAttribute("Table 1.Cells[2,1]", "Text") = "Text 2,1"
.ObjectAttribute("Table 1.Cells[2,2]", "Text") = "Text 2,2"


' Add a new row
.PDF1.ObjectAttribute("Table 1", "Rows") = .PDF1.ObjectAttribute("Table 1", "Rows") + 1

End With
End Sub
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

There are a couple of methods available that will allow you to add rows to a table. The method you have described will re-initialize the table.

If you wish to add a row and keep the existing table data please us the code snippet below:

Private Sub cmdAddRow_Click()
Dim intRows As Integer
Dim intRowWidth As Integer

With PDF1
'Open PDF document which includes the table object that you
'want to add rows to.
.Open App.Path & "\sample.pdf", ""

'Put the Documetn into design mode
.DoCommandTool (acCommandToolDesignMode)

'Active the object
.ActivateObject "Table 1"

'Find number of rows in the opened document
intRows = .ObjectAttribute("Table 1", "Rows")

'Get width of Table object
intRowWidth = (.ObjectAttribute("Table 1", "Bottom")) - _
(.ObjectAttribute("Table 1", "Top"))

'Insert new row into Table
.DoCommandTool (acCommandToolInsertRow)

'Inlarge Table in order to add ne row
' Table Bottom = Table width / number of rows
.ObjectAttribute("Table 1", "Bottom") = CInt(intRowWidth / intRows) + _
CInt(.ObjectAttribute("Table 1", "Bottom"))

'Compile new document
.DoCommandTool (acCommandToolRunDocument)

.Refresh
.Save App.Path & "\sample_revised.pdf", 0
End With
End Sub

Thanks
Randal
Posts: 9
Joined: Mon Sep 22 2003

Works fine!

Post by Randal »

It works fine...

Thanks!
Post Reply