How to copy table context to another table

Creating a macro - Writing a Script - Using the API

How to copy table context to another table

Postby zenira » Sun Apr 02, 2017 6:37 pm

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
Attachments
CopyTableContext.odt
example file
(14.17 KiB) Downloaded 35 times
LibreOffice 4.1.0.4 on Windows 7
zenira
 
Posts: 85
Joined: Sun May 11, 2014 11:24 am

Re: How to copy table context to another table

Postby zenira » Mon Apr 03, 2017 7:30 pm

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)
LibreOffice 4.1.0.4 on Windows 7
zenira
 
Posts: 85
Joined: Sun May 11, 2014 11:24 am

Re: How to copy table context to another table

Postby UnklDonald418 » Tue Apr 04, 2017 9:26 pm

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.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.4 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 575
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 8 guests