Inserting a Row and Copy Functions Macro
Inserting a Row and Copy Functions Macro
I'm trying to create a macro linked to a Form Control button to insert a new row above whatever cell is currently active. After the row has been inserted it needs to copy the conditional formatting and functions of the previous row without duplicating the data.
I've perused many posts, the closest of which was this one: http://user.services.openoffice.org/en/ ... +row+macro
The difference between what I need and what the aforementioned post accomplishes is that the active cell will not be at the bottom of the page.
I've tried recording macros and even browsed through a few tutorials (Hello World, Databases, etc), but none of what I've been able to find pertains to a row that is relative to the currently selected cell. I don't know that it makes a huge difference but a lot of the functions I need are in hidden columns.
It looks like this
Date Category Qty
xx/xx Screws 4 (functions in hidden columns)
xx/xx Eyebolts 6 (functions in hidden columns)
xx/xx Clamps 2 (functions in hidden columns)
xx/xx Eyebolts 9 (functions in hidden columns)
<- Need to insert here ->
Total Screws 4
Total Eyebolts 15
Total Clamps 2
Total Washers 0
Thanks in advance for any thoughts!
I've perused many posts, the closest of which was this one: http://user.services.openoffice.org/en/ ... +row+macro
The difference between what I need and what the aforementioned post accomplishes is that the active cell will not be at the bottom of the page.
I've tried recording macros and even browsed through a few tutorials (Hello World, Databases, etc), but none of what I've been able to find pertains to a row that is relative to the currently selected cell. I don't know that it makes a huge difference but a lot of the functions I need are in hidden columns.
It looks like this
Date Category Qty
xx/xx Screws 4 (functions in hidden columns)
xx/xx Eyebolts 6 (functions in hidden columns)
xx/xx Clamps 2 (functions in hidden columns)
xx/xx Eyebolts 9 (functions in hidden columns)
<- Need to insert here ->
Total Screws 4
Total Eyebolts 15
Total Clamps 2
Total Washers 0
Thanks in advance for any thoughts!
OpenOffice 3.3.0, Win7
Re: Inserting a Row and Copy Functions Macro
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Inserting a Row and Copy Functions Macro
Is this possible with a non-python macro embedded within the spreadsheet?
OpenOffice 3.3.0, Win7
Re: Inserting a Row and Copy Functions Macro
Hi
May be, it is - but why not with embedded python-script ? KaroIs this possible with a non-python macro embedded within the spreadsheet?
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
Re: Inserting a Row and Copy Functions Macro
Maybe because embedding a python script into a OpenOffice Spreadsheet isn't easy to accomplish, neither is it well documented. I see that the .py file is included in the zip-archive of the Spreadsheet that you uploaded and there is an entry in the manifest.xml for it. But how did you get there?karolus wrote:HiMay be, it is - but why not with embedded python-script ?Is this possible with a non-python macro embedded within the spreadsheet?
Karo
Code: Select all
<manifest:file-entry manifest:media-type="" manifest:full-path="Scripts/python/embeded_python_lib.py"/>
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
Re: Inserting a Row and Copy Functions Macro
Hi
http://hermione.s41.xrea.com/pukiwiki/i ... bbs2%2F194
But its also possible to do it the hard way on a closed Document:
For my convinience, actually i do it with Help of 'ModifiedScriptProvider.oxt' and 'EditorKicker...oxt' from Hanya:rudolfo wrote:Maybe because embedding a python script into a OpenOffice Spreadsheet isn't easy to accomplish, neither is it well documented. I see that the .py file is included in the zip-archive of the Spreadsheet that you uploaded and there is an entry in the manifest.xml for it. But how did you get there?karolus wrote:HiMay be, it is - but why not with embedded python-script ?Is this possible with a non-python macro embedded within the spreadsheet?
Karo
http://hermione.s41.xrea.com/pukiwiki/i ... bbs2%2F194
But its also possible to do it the hard way on a closed Document:
- > unzip xyz.ods -d newfolder
> cd newfolder
> mkdir Scripts
> mkdir Scripts/python
> cp /path/to/your_script.py Scripts/python
at the end put it back to .ods -file with:<manifest:file-entry manifest:media-type="" manifest:full-path="Scripts/python/your_script.py"/>
<manifest:file-entry manifest:media-type="application/binary" manifest:full-path="Scripts/python/"/>
<manifest:file-entry manifest:media-type="application/binary" manifest:full-path="Scripts/"/>
- > ls | zip -r@ new_calc_python.ods
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
- kingfisher
- Volunteer
- Posts: 2123
- Joined: Tue Nov 20, 2007 10:53 am
Re: Inserting a Row and Copy Functions Macro
The way I add a row to tables involves defining the tables as database ranges. This is one example:
Code: Select all
'Define the codes table. 'Insert a row at the end of the Codes table.
' EXAMPLE ONLY
oDBase = vDBases.getByName( "_TableCodes" )
oCells = oDBase.ReferredCells : oDocSheet = oCells.Spreadsheet
lFoot = oCells.RangeAddress.EndRow + 1 : oDocSheet.Rows.insertByIndex( lFoot, 1 )
oExtDBase = oDBase : lNum = 1 : Call extDBRows : oDoc.calculateAll()
oDBase = oExtDBase.ReferredCells : lLeft = lDBLeft : lFoot = lDBFoot
'Insert the new code in the last cell of the table.
oCell = oDocSheet.getCellByPosition( lLeft, lFoot ) : oCell.setString( UCase( sCode ) )
If oDoc.StyleFamilies.CellStyles.hasByName( "_Titles" ) Then : oCell.CellStyle = "_Titles" : End If
'Sort the table in alphabetical order.
Dim aSortField( 0 ) as new com.sun.star.util.SortField, _
aSortVal( 1 ) as new com.sun.star.beans.PropertyValue
aSortField( 0 ).Field = 0 : aSortField( 0 ).SortAscending = TRUE
aSortVal( 0 ).Name = "SortFields" : aSortVal( 0 ).Value = aSortField()
aSortVal( 1 ).Name = "ContainsHeader" : aSortVal( 1 ).Value = true
oDBase.Sort( aSortVal() )
Apache OpenOffice 4.1.9 on Linux
Re: Inserting a Row and Copy Functions Macro
Thank you karolus for this demo how to wrap script code into documents.
However, my pair of Python macros is designed to extend the capability of the whole Calc component. It does not depend on the properties of a certain Calc document. There is no need to adjust the source code to specific ranges, styles nor other attributes. Therefore I do not understand why it should be restricted to a particular document.
It operates on the current range selection (in case of no range selection that is the active cell) taking care that all references expand to the resized range as you would expect from a growing and shrinking list range, regardless if that is a database range, named range, chart range and no matter which formula expressions refer to the involved cells. You can turn off the obscure and sometimes annoying "expand reference" option while using the advantages of that option when working with a list. I use this code since years and never got any error message nor did I lose any of my references nor formulas even when the formulas are in hidden columns. Unlike Basic code it does not fail when you call it many times while the first calls are not yet finished.
This pair of macros could be distributed as an extension. But why should I struggle with extension packaging when dropping a script into the user profile or application profile is so easy?
However, my pair of Python macros is designed to extend the capability of the whole Calc component. It does not depend on the properties of a certain Calc document. There is no need to adjust the source code to specific ranges, styles nor other attributes. Therefore I do not understand why it should be restricted to a particular document.
It operates on the current range selection (in case of no range selection that is the active cell) taking care that all references expand to the resized range as you would expect from a growing and shrinking list range, regardless if that is a database range, named range, chart range and no matter which formula expressions refer to the involved cells. You can turn off the obscure and sometimes annoying "expand reference" option while using the advantages of that option when working with a list. I use this code since years and never got any error message nor did I lose any of my references nor formulas even when the formulas are in hidden columns. Unlike Basic code it does not fail when you call it many times while the first calls are not yet finished.
This pair of macros could be distributed as an extension. But why should I struggle with extension packaging when dropping a script into the user profile or application profile is so easy?
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Inserting a Row and Copy Functions Macro
Hallo
Karo
Yes, i know, my post is only a reply to the Question:Villeroy wrote:Thank you karolus for this demo how to wrap script code into documents.
However, my pair of Python macros is designed to extend the capability of the whole Calc component. It does not depend on the properties of a certain Calc document. There is no need to adjust the source code to specific ranges, styles nor other attributes.
nsoon wrote:Is this possible with a non-python macro embedded within the spreadsheet?
+1 ... but think about some users wich are in trouble to find the 'user profile' ...Villeroy wrote:....
This pair of macros could be distributed as an extension. But why should I struggle with extension packaging when dropping a script into the user profile or application profile is so easy?
Karo
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
Re: Inserting a Row and Copy Functions Macro
Well, I try my best to ignore this category of non-users.karolus wrote:Hallo+1 ... but think about some users wich are in trouble to find the 'user profile' ...Villeroy wrote:....
This pair of macros could be distributed as an extension. But why should I struggle with extension packaging when dropping a script into the user profile or application profile is so easy?
Karo
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice