OpenOffice Macros with Basic

Create new Macro
Extras > Makros > Makros verwalten > Makro...
Meine Makros > Standard > Neu

# open a external application (v1)
Sub Main
item = ThisComponent.getCurrentSelection.String

If len(item) > 0 then
rem msgbox "Selection: " & item

item = UCase(item)
oService = createUnoService("com.sun.star.system.SystemShellExecute")
oService.execute("/media/programme/starter/scripts/Lager.sh", "item_id=" & item, 0)
EndIf
End Sub

# open a external application (v2)
Sub Main
selectedRow = ThisComponent.CurrentSelection.getRangeAddress.StartRow
itemId = ThisComponent.CurrentController.ActiveSheet.getCellByPosition(0, selectedRow).getString()

oSysExecuteService = createUnoService("com.sun.star.system.SystemShellExecute")
oSysExecuteService.execute("/media/programme/starter/scripts/Lager.sh", "item_id=" & itemId, 0)

rem MsgBox itemId, 0
rem ThisComponent.CurrentSelection.getString()
End Sub

# print file name in a frame
Sub Main
rem get graphic file name
graphic = ThisComponent.getGraphicObjects.getByName("Grafik1")
filePath = graphic.GraphicURL rem get graphic url
filePathArray() = Split(filePath, "/") rem split path
filePathArrayLength = UBOUND(filePathArray) rem get array length
fileName = filePathArray(filePathArrayLength) rem get last arry part
fileName = join(split(fileName, ".jpg"), "") rem remove ".jpg" file extension

rem msgbox fileName

rem write fileName to frame
frame = ThisComponent.TextFrames.getByName("Rahmen1")
oCursor = frame.CreateTextCursor
oCursor.gotoEnd(True)
oCursor.String = fileName
End Sub

Create symbol menu with Macros
Extras > Anpassen...
Symbolleisten > Neu...

Links
http://www.linux-user.de/ausgabe/2005/02/036-oo/index.html
http://www.ooowiki.de/StarBasic