Page 1 of 1

How to copy table context to another table

PostPosted: Sun Apr 02, 2017 6:37 pm
by zenira
hi friends
I want to copy all table context into other table. Table has paragragh and numering context. I always get same message
5gD31z.jpg

V0rGoP.jpg

Code: Select all   Expand viewCollapse view
Option Explicit
dim Table1,Table2,Table1cell,Table2cell as object

Sub Main

Table1=ThisComponent.TextTables.getByName("Table1")
Table1Cell=Table1.getCellByName("A1")
Table2=ThisComponent.TextTables.getByName("Table2")
Table2Cell=Table2.getCellByName("A1")

dim Enum1,Cursor as object
dim Para as object

Enum1=Table1Cell.createEnumeration
Cursor=Table2Cell.createTextCursor

while Enum1.hasMoreElements
   Para=Enum1.NextElement()
   Table2Cell.insertTextContent(Cursor.getEnd(),Para.getText, False)
wend

End Sub

thanks for your advice

Re: How to copy table context to another table

PostPosted: Mon Apr 03, 2017 7:30 pm
by zenira
I can get string and paste it correctly but it destroys the format
Code: Select all   Expand viewCollapse view
Table2Cell.insertTextContent(Cursor.getEnd(),Para.getString, False)

Re: How to copy table context to another table

PostPosted: Tue Apr 04, 2017 9:26 pm
by UnklDonald418
Have you looked at Andrew Pitonyak's examples in his book “OpenOffice.org Macros Explained”?
Listing 381 copies and pastes a named Writer table using the clipboard, so all the formatting is preserved.