yes it is,
take something from the following code - it does additional things, like first saving a timestamped copy - but in the end it closes the file and reopens it.
was useful while struggeling with calc becoming slow after saving of files with plenty comments, that behaviour is - nearly - off in ver. 6.2.7.1 (it came back with subsequent versions), but the macro functionality may be useful for other users for other purposes …
sub schliessenoeffnen '--------------------------br-06.09.2019
Dim oDoc, oForm, oblatt, oDatei as Object
' remember file
odoc = thiscomponent
speicherOrt = ConvertFromUrl(odoc.getLocation)
' strip if timestamped, apply new timestamp, save
extens = Right(speicherort,4)
dateilen = len(speicherort)-4
dateibase = left(speicherort, len(speicherort)-4)
tail = right(dateibase,17)
tlen = Len(Tail)
pos1 = instr(tail,"_")
pos2 = instr(tail,"-")
if pos1 > 0 and pos2 > 0 then
if pos1+ 5 <> pos2 then
notimestamp = true
else
if Mid(tail, pos1+ 11, 1) <> "_" or Mid(tail, pos1+ 8, 1) <> "-" or Mid(tail, pos1+ 14, 1) <> "-" then
notimestamp = true
else
dateibase = left(dateibase,len(Dateibase)-tlen) 'strip old timestamp
end if
end if
dateibase = dateibase & "_" & Format(Now(),"YYYY-MM-DD") & "_" & format(time(),"HH-MM" 'add new timestamp
else
dateibase = dateibase & "_" & Format(Now(),"YYYY-MM-DD") & "_" & format(time(),"HH-MM"
end if
' save file
fname = dateibase & extens
surl = converttourl(fname)
dim dummy()
odoc.storeasurl(surl,dummy())
' Formular schliessen
oDoc = thisComponent.currentController.frame
oDispatch = createUnoService("com.sun.star.frame.DispatchHelper")
oDispatch.executeDispatch(oDoc, ".uno:CloseDoc", "", 0, Array())
' Formular öffnen
DIM sDatei, sPfad as string
oDoc = ThisComponent
sDatei = fname
sUrl_1 = ConvertToURL(sDatei) 'Umwandeln URL
sPfad = "scalc.exe" 'Pfad der zu verwendenden Applikation
Shell(sPfad + " " + sDatei,3) 'nun öffnen der Datei mit dem angegebenen Programm
end sub 'schliessenoeffnen
sorry - i tried! to insert as code - it didn’t work,
sorry - parts are in german,
beware - i did some prettyfying before insert - thus may be buggy,
reg.
b.
P.S. is there a way to insert ‘code’ as a block? i couldn’t find, had to do it line by line, otherwise it (expletive deleted) the formatting … painful