Cercherò di essere più preciso ed esaustivo.
Ho creato un foglio di calcolo dove inserisco le prenotazioni dei ricoveri per l'azienda per cui lavoro.
Sono presenti tra gli altri i seguenti campi Cognome Nome e data di prenotazione.
Ho creato un pulsante associandogli una macro creata con "Registra macro" che mi inserisce la data e l'ora di inserimento della prenotazione.
Eccola:
_______________________________________________________________________________
sub SfondoBianco
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 1
args2(1).Name = "Sel"
args2(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoDownToEndOfData", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1
args3(1).Name = "Sel"
args3(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRightToEndOfData", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(1) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 1
args4(1).Name = "Sel"
args4(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRightToEndOfData", "", 0, args4())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertCurrentTime", "", 0, Array())
rem ----------------------------------------------------------------------
dim args6(1) as new com.sun.star.beans.PropertyValue
args6(0).Name = "By"
args6(0).Value = 1
args6(1).Name = "Sel"
args6(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args6())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertCurrentDate", "", 0, Array())
rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "NumberFormatValue"
args8(0).Value = 36
dispatcher.executeDispatch(document, ".uno:NumberFormatValue", "", 0, args8())
rem ----------------------------------------------------------------------
dim args9(1) as new com.sun.star.beans.PropertyValue
args9(0).Name = "By"
args9(0).Value = 1
args9(1).Name = "Sel"
args9(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeftToStartOfData", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(1) as new com.sun.star.beans.PropertyValue
args10(0).Name = "By"
args10(0).Value = 1
args10(1).Name = "Sel"
args10(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeftToStartOfData", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "By"
args11(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightToEndOfDataSel", "", 0, args11())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ResetAttributes", "", 0, Array())
rem ----------------------------------------------------------------------
dim args13(1) as new com.sun.star.beans.PropertyValue
args13(0).Name = "By"
args13(0).Value = 1
args13(1).Name = "Sel"
args13(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeftToStartOfData", "", 0, args13())
rem ----------------------------------------------------------------------
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "ToPoint"
args14(0).Value = "$B$5"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args14())
rem ----------------------------------------------------------------------
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "ToPoint"
args15(0).Value = "$A$3"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args15())
rem ----------------------------------------------------------------------
dim args16(1) as new com.sun.star.beans.PropertyValue
args16(0).Name = "By"
args16(0).Value = 1
args16(1).Name = "Sel"
args16(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeftToStartOfData", "", 0, args16())
rem ----------------------------------------------------------------------
dim args17(0) as new com.sun.star.beans.PropertyValue
args17(0).Name = "By"
args17(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args17())
rem ----------------------------------------------------------------------
dim args18(0) as new com.sun.star.beans.PropertyValue
args18(0).Name = "By"
args18(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args18())
rem ----------------------------------------------------------------------
dim args19(0) as new com.sun.star.beans.PropertyValue
args19(0).Name = "NumberFormatValue"
args19(0).Value = 36
dispatcher.executeDispatch(document, ".uno:NumberFormatValue", "", 0, args19())
rem ----------------------------------------------------------------------
dim args20(1) as new com.sun.star.beans.PropertyValue
args20(0).Name = "By"
args20(0).Value = 1
args20(1).Name = "Sel"
args20(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeftToStartOfData", "", 0, args20())
rem ----------------------------------------------------------------------
dim args21(1) as new com.sun.star.beans.PropertyValue
args21(0).Name = "By"
args21(0).Value = 1
args21(1).Name = "Sel"
args21(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args21())
rem ----------------------------------------------------------------------
dim args22(0) as new com.sun.star.beans.PropertyValue
args22(0).Name = "By"
args22(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightToEndOfDataSel", "", 0, args22())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:BorderTLBR", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:BorderBLTR", "", 0, Array())
rem ----------------------------------------------------------------------
dim args25(7) as new com.sun.star.beans.PropertyValue
args25(0).Name = "BorderOuter.LeftBorder"
args25(0).Value = Array(0,0,26,0,0,26)
args25(1).Name = "BorderOuter.LeftDistance"
args25(1).Value = 0
args25(2).Name = "BorderOuter.RightBorder"
args25(2).Value = Array(0,0,26,0,0,26)
args25(3).Name = "BorderOuter.RightDistance"
args25(3).Value = 0
args25(4).Name = "BorderOuter.TopBorder"
args25(4).Value = Array(0,0,26,0,0,26)
args25(5).Name = "BorderOuter.TopDistance"
args25(5).Value = 0
args25(6).Name = "BorderOuter.BottomBorder"
args25(6).Value = Array(0,0,26,0,0,26)
args25(7).Name = "BorderOuter.BottomDistance"
args25(7).Value = 0
dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args25())
rem ----------------------------------------------------------------------
dim args26(4) as new com.sun.star.beans.PropertyValue
args26(0).Name = "BorderInner.Horizontal"
args26(0).Value = Array(0,0,0,0,0,0)
args26(1).Name = "BorderInner.Vertical"
args26(1).Value = Array(0,0,26,0,0,26)
args26(2).Name = "BorderInner.Flags"
args26(2).Value = 2
args26(3).Name = "BorderInner.ValidFlags"
args26(3).Value = 127
args26(4).Name = "BorderInner.DefaultDistance"
args26(4).Value = 0
dispatcher.executeDispatch(document, ".uno:BorderInner", "", 0, args26())
rem ----------------------------------------------------------------------
dim args27(1) as new com.sun.star.beans.PropertyValue
args27(0).Name = "By"
args27(0).Value = 1
args27(1).Name = "Sel"
args27(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args27())
end sub
_______________________________________________________________________________
l'ho registrata in: Macro personali --> Standard --> Module1
Quando l'ho creata dal mio PC di casa collegandomi in remoto su un server virtuale dell'azienda, lavorando quindi sul file che avrebbero dovuto usare gli utenti, facendo le prove da casa mia, in questo modo, la macro mi funziona, ma quando vado in ufficio e provo a far funzionare la macro con LibreOffice caricato su ogni terminale, la macro non funziona.
Ora mi chiedevo il perché e sarei grato se qualcuno possa illuminarmi sulla questione. Tralasciando il nome della macro che penso non sia influente.
Spero di essere stato abbastanza esaustivo .
Grazie