Ještě jednou prosím o konzultaci 
Pokud to začlením do procedury nebo zadávám masku přímo ve FUNCTION, funguje to. Ale když se pokouším předat formátovací masku jako argument funkci nebo proceduře, křičí na mě a nechce o tom ani slyšet. Nechce to převzít ani jako řetězec z buňky. Možná v tom bude nějaká banální chyba, ale já jí nevidím.
sub ...
    Fondy = thisComponent
    Strana_1 = Fondy.sheets(1)
    Strana_3 = Fondy.sheets(3)
...
...
rem varianta 1
        Dim Num_form as object
    Num_form = Strana_3.getcellbyposition(14,4)
        Num_form.string = "# ##0,0000"
        cell = Strana_1.getcellbyposition(1,1)
        Numer_Format(cell)
rem varianta 2
        Dim Num_form as string
    Num_form = "# ##0,0000" 
    cell = Strana_1.getcellbyposition(1,1)
    Numer_Format(cell,Num_form)
end sub            
+ varianta 1
Function Numer_Format(cell)
    Fondy = thisComponent
    Strana_3 = Fondy.sheets(3)
    Dim NumberFormats As Object
    Dim NumberFormatId As Long
        dim NumberFormatString as string
    Dim LocalSettings As New com.sun.star.lang.Locale
        NumberFormatString = Strana_3.getcellbyposition(14,4).string rem předání hodnoty buňkou
          rem oSheet=fondy.getSheets().getByName("List1")
          rem oCell=oSheet.getCellByPosition(1,1)    'B1
        NumberFormats = Fondy.NumberFormats
        NumberFormatId = NumberFormats.queryKey(NumberFormatString,LocalSettings,true)
        If NumberFormatId = -1 Then
           NumberFormatId = NumberFormats.addNew(NumberFormatString,LocalSettings)
        End If
        Cell.NumberFormat = NumberFormatId
        msgbox "šlus jako hotovo - buňka B1 má naformátováno"
End function
+ varianta 2
Function Numer_Format(cell,NumberFormatString) rem předání hodnoty argumentem
    Fondy = thisComponent
    Strana_3 = Fondy.sheets(3)
    Dim NumberFormats As Object
    Dim NumberFormatId As Long
         dim NumberFormatString as string  rem nevím, jestli deklarace není nadbytečná
     Dim LocalSettings As New com.sun.star.lang.Locale
                  rem oSheet=fondy.getSheets().getByName("List1")
          rem oCell=oSheet.getCellByPosition(1,1)    'B1
        NumberFormats = Fondy.NumberFormats
        NumberFormatId = NumberFormats.queryKey(NumberFormatString,LocalSettings,true)
        If NumberFormatId = -1 Then
           NumberFormatId = NumberFormats.addNew(NumberFormatString,LocalSettings) rem zde Basic urputně hlásí "Vyskytla se výjimka Type:com.sun.star.uno.RuntimeExcepcion Mesage:."
        End If
        Cell.NumberFormat = NumberFormatId
        msgbox "šlus jako hotovo - buňka B1 má naformátováno"
End function
Už se tím trápím asi 3 hodiny, ale nemůžu to přelomit. Vzhledem k tomu, že to chci používat na více místech a třeba bych rád měl variabilní masku, uvítal bych to jako funkci nebo samostanou proceduru. Pokud to nepůjde, je varianta formátovat bloky buněk přes nějaký cyklus - ale to už se mi tak nelíbí.
Díky za trpělivost
Martin