[Solved] How to copy a calc table in a Base table by macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
briglia23
Posts: 155
Joined: Tue Jun 24, 2008 10:09 am

[Solved] How to copy a calc table in a Base table by macro

Post by briglia23 »

Who can help me?
I know how to do this manually but i can't do by macro.
Thanks a lot
Last edited by briglia23 on Mon Jul 14, 2008 3:58 pm, edited 1 time in total.
OOo 2.3.X on openSuse 10
QuazzieEvil
Volunteer
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: how to copy a calc table in a Base table by macro

Post by QuazzieEvil »

do you mean you have data in a spreadsheet which you want to migrate into a Base table?
briglia23
Posts: 155
Joined: Tue Jun 24, 2008 10:09 am

Re: how to copy a calc table in a Base table by macro

Post by briglia23 »

Yes
OOo 2.3.X on openSuse 10
User avatar
estatistics
Posts: 25
Joined: Tue Oct 13, 2015 8:13 pm
Location: worldwide

Re: [Solved] How to copy a calc table in a Base table by mac

Post by estatistics »

This code may helps you.

You must name a calc sheet, then macro creates a blank writer document and transfer table data to this document according to the ranges that exist in a specific cell.

Code: Select all

' XrayTool that helps to investigate VBA objects. 
' Found here: https://berma.pagesperso-orange.fr/index2.html 
' Download word document and click the button inside to install 
' it.

Sub LoadingLibraries
 BasicLibraries.LoadLibrary("XrayTool")
End Sub


Sub CopyChartstoWriter
'Definitions of variables

'Calc Dims
Dim oSheet    'Sheet containing the chart
Dim oDoc
'Document Dims
Dim oDocWriter  as object
Dim sUrl$ 
Dim oVCur       as object
Dim oDocument   as object
Dim oDispatcher as object

  
oDoc              = ThisComponent
oSheets           = ThisComponent.getSheets()
oSheetTables      = oSheets.getbyName( "Tables_stat"  ) 

'Set of Ranges of Table Data in a specific cell created by Concat and formulas
TableDataRanges  	   = oSheetTables.getCellRangeByName("E16")
split_TableDataRanges  = Split(TableDataRanges.String,",")



	sUrl="private:factory/swriter"                                              'new writer document
	'sUrl=ConvertToUrl("d:/documents/example.odt") 'or your writer file
	oDocWriter    = StarDesktop.LoadComponentFromUrl(sURL, "_blank", 0, array()) 'open Writer document

	oDispatcher   = createUnoService("com.sun.star.frame.DispatchHelper")
	oDocument     = ThisComponent.CurrentController.Frame
	
	
	NumberofTables = 2   												         
	cNumber        = NumberofTables/10 

	for n = 0 to 260 * cNumber step 1		 								         'Create ~5*cNumber Pages using Enter->"para".
	oDispatcher.executeDispatch(oDocument,  ".uno:InsertPara", "", 0, Array())
    next n

	For i = 0 to ( NumberofTables - 1 ) step 1   										'1+1 Chart/Table per Table. How Many?
	
	    oTableData          = oSheetTables.getCellRangeByName( split_TableDataRanges(i) )
   
		    'Transfer Table Data into Writer (copy and then Paste them)
			                 oDoc.CurrentController.select( oTableData )    
			oTableData     = oDoc.CurrentController.getTransferable()
			oVCur          = oDocWriter.CurrentController.getViewCursor     				 'visible cursor
		                     oDocWriter.CurrentController.Select( oVCur )    				 'select visible cursor
		                 
		    ' Optimizing in which position Table Data will be placed 
		                  	 oVCur.JumpToPage( i + 1, False)   
		                     oDocWriter.CurrentController.insertTransferable( oTableData )   'Libre internal Ctrl+V

	next i

end sub 
OpenOffice 4.2.8.2 on Lubuntu
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] How to copy a calc table in a Base table by mac

Post by Villeroy »

Base, Calc, Python: INSERT, UPDATE, DELETE from spreadsheet
estatistics wrote:' XrayTool that helps to investigate VBA objects.
There is no VBA in LibreOffice nor OpenOffice.
Xray is commendable but outdated. MRI is better. [Tutorial] Introduction into object inspection with MRI
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
estatistics
Posts: 25
Joined: Tue Oct 13, 2015 8:13 pm
Location: worldwide

Re: [Solved] How to copy a calc table in a Base table by mac

Post by estatistics »

Version 1.4 had problems - did not install. Version 1.2 did installed but could not get it to work.

If I understood right, you install the plugin .oxt and then you use inside the macro code mri object.x. Right?
OpenOffice 4.2.8.2 on Lubuntu
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] How to copy a calc table in a Base table by mac

Post by Villeroy »

I use version 1.3.4 on Linux.
I call it from the Tools menu or

Code: Select all

objMri = createUnoService("mytools.Mri")
objMri.Inspect(obj) 
or

Code: Select all

GlobalScope.BasicLibraries.loadLibrary("MRILib")
mri obj
which does exactly the same as the former snippet.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] How to copy a calc table in a Base table by mac

Post by Villeroy »

On topic: Base, Calc, Python: INSERT, UPDATE, DELETE from spreadsheet can be used to write data from Calc to any type of writable database connection.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
estatistics
Posts: 25
Joined: Tue Oct 13, 2015 8:13 pm
Location: worldwide

Re: [Solved] How to copy a calc table in a Base table by mac

Post by estatistics »

Villeroy wrote:

Code: Select all

GlobalScope.BasicLibraries.loadLibrary("MRILib")
mri obj
which does exactly the same as the former snippet.
See attached picture. Mri creating exception. I do not why.
Attachments
mri problem
mri problem
OpenOffice 4.2.8.2 on Lubuntu
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] How to copy a calc table in a Base table by mac

Post by Villeroy »

You forgot to install the extension? Is there any menu Tools>Addins>Mri? Can you create UNO service "mytools.Mri"?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
estatistics
Posts: 25
Joined: Tue Oct 13, 2015 8:13 pm
Location: worldwide

Re: [Solved] How to copy a calc table in a Base table by mac

Post by estatistics »

Villeroy wrote:You forgot to install the extension? Is there any menu Tools>Addins>Mri? Can you create UNO service "mytools.Mri"?
See attached video.
Before installation i had no menu as Add-ons MRI. Even installation failed, MRI created these menu entries. So I thought it was installed.

I Dont have any menu as "addins". I have extension manager.


https://streamable.com/gidyd3
OpenOffice 4.2.8.2 on Lubuntu
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] How to copy a calc table in a Base table by mac

Post by Villeroy »

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
estatistics
Posts: 25
Joined: Tue Oct 13, 2015 8:13 pm
Location: worldwide

Re: [Solved] How to copy a calc table in a Base table by mac

Post by estatistics »

Both MRI entries in Tools-->Addons menu are doing nothing. I click on them and nothing happens.

To fill a bug maybe?
OpenOffice 4.2.8.2 on Lubuntu
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] How to copy a calc table in a Base table by mac

Post by Villeroy »

Who knows? May be you did a custom installation and deselected Python? Custom installations are a bad idea and show many problem discussed in this forum. Without Base Writer can not do mail merge. WIthout Draw drawing capabilities are limited. Without Python a huge amount of extensions and macros can't work. Personally, I remove update notification and "quick starter" because I know which version I want to install when and the quick starter is a major source of trouble, for instance when you install an extension and restart the office but the office is not really restarted due to the "quick starter".
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
estatistics
Posts: 25
Joined: Tue Oct 13, 2015 8:13 pm
Location: worldwide

Re: [Solved] How to copy a calc table in a Base table by mac

Post by estatistics »

Custom installation about Libre? No. I installed the mri plugin by downloading it, and then double click it. and then extension menu opened and tried to install it. Thanks for your help.
OpenOffice 4.2.8.2 on Lubuntu
User avatar
karolus
Volunteer
Posts: 1158
Joined: Sat Jul 02, 2011 9:47 am

Re: [Solved] How to copy a calc table in a Base table by mac

Post by karolus »

AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] How to copy a calc table in a Base table by mac

Post by Villeroy »

karolus wrote:Try MRI1.3.4 from github
https://github.com/hanya/MRI/releases/tag/v1.3.4
Yep, this is the one I use with AOO, LO 6 and 7 on mostly on Linux but Windows as well.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply