Menu: | Tools -> Macros -> Organize macros -> OpenOffice.org Basic... |
Window: | OpenOffice.org Basic Macros |
Area: | Macro from |
Treeview: | [-]<Select your spreadsheet> |
Mark: | [-] Standard |
Button: | [ New ] |
Window: | New Module |
Field: | Name: |
Keyboard: | GetSheetName |
Button: | [ OK ] |
Window: | <Your spreadsheets name> - OpenOffice.org Basic |
Function GetSheetName( i )
On Error Goto trap
GetSheetName = ThisComponent.Sheets(i-1).Name
Exit Function
trap:
GetSheetName = erl()
End Function
Menu: | File -> Save |
Menu: | File -> Close |
Spreadsheet: | Select a cell |
Keyboard: | =getsheetname(3) |
Keyboard: | Enter |
/*
* Filename: OOorgMacro.cmd
* Author: JAN-ERIK
* Created: Wed Apr 16 2014
* Purpose: Add macro security tag to configuration file to be able to run Macros in the OS/2 and eComstaiton version of OpenOffice.org
* Changes:
*/
/* Load RexxUtil Library */
IF RxFuncQuery('SysLoadFuncs') THEN
DO
CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
CALL SysLoadFuncs
END
CALL SysCls
CALL LINEOUT 'STDERR', 'OpenOffice.org for OS/2 and eComstation'
CALL LINEOUT 'STDERR', "doesn't contain a utility to allow you to enable macros"
CALL LINEOUT 'STDERR', ''
CALL LINEOUT 'STDERR', 'This script will attempt to enable macro security for you.'
CALL LINEOUT 'STDERR', ''
CALL LINEOUT 'STDERR', 'Please do note that you should be aware that macros may'
CALL LINEOUT 'STDERR', "be harmful so don't open files from unknown sources or"
CALL LINEOUT 'STDERR', 'files that may contain macros.'
CALL LINEOUT 'STDERR', ''
CALL LINEOUT 'STDERR', "Don't blame the author of this script for any harm caused!"
CALL LINEOUT 'STDERR', ''
CALL CHAROUT 'STDERR', 'Do you want to continue (yes/No)? (N by default) '
PARSE PULL answer
IF TRANSLATE( LEFT( answer, 1 ) ) <> 'Y' THEN RETURN 0
level = ' '
DO WHILE \DATATYPE( level, 'W' )
CALL LINEOUT 'STDERR', ''
CALL LINEOUT 'STDERR', 'Valid values are: 0 - the lowest; 1 - the lower; 2 - default; 3 - the highest'
CALL LINEOUT 'STDERR', ''
CALL CHAROUT 'STDERR', 'Specify the security level to use (4 and above to abort): '
PARSE PULL level
IF level = '' THEN level = 2
IF level < 0 THEN level = ' '
IF level > 3 THEN RETURN level
END
newln = D2C(10)
add.1 = '<node oor:name="Security">'
add.2 = ' <node oor:name="Scripting">'
add.3 = ' <prop oor:name="MacroSecurityLevel" oor:type="xs:int">'
add.4 = ' <value>'||level||'</value>'
add.5 = ' </prop>'
add.6 = ' </node>'
add.7 = '</node>'
add.8 = '</oor:component-data>'
add.0 = 8
CALL CHAROUT 'STDERR', '.'
home_dir = VALUE( 'HOME',, 'OS2ENVIRONMENT' )
IF SysFileTree( home_dir||'\*common.xcu', 'file.', 'SFO' ) = 0 THEN
DO i = 1 TO file.0
f_size = STREAM( file.i, 'C', 'QUERY SIZE' )
IF f_size = 0 THEN ITERATE
input = CHARIN( file.i, 1, f_size )
CALL STREAM file.i, 'C', 'CLOSE'
PARSE VALUE input WITH pre(add.8).
PARSE VALUE pre WITH pre(add.1).
DO j = 1 TO add.0
CALL CHAROUT 'STDERR', '.'
pre = pre||add.j
IF j < add.0 THEN
pre = pre||newln
END
IF SysFileDelete( file.i ) = 0 THEN
CALL CHAROUT file.i, pre
CALL CHAROUT 'STDERR', '.'
END