hello,
i ve written some small macro that save and close the document after x minutes.
the document get closed, but next start time the crash report is opened.
i try several methods to save the document, but always the same.
The button toggle an not visible flag,
the macro is called after open the document.
Sub toggle_auto_exit_timer
oBreak = ThisComponent.CurrentController.ActiveSheet.DrawPage.Forms.getByIndex(0).getByName("autoclose_exit")
if oBreak.State > 0 then
oBreak.State = 0
else
oBreak.State = 1
end if
End Sub
Sub auto_exit_timer
DIM timer as string
DIM oDocument as object
DIM auto_close_time as string
auto_close_time = "00:00:20"
start_time = Time
end_time = TimeValue(start_time) + TimeValue(auto_close_time)
oDocument = ThisComponent
oButton = oDocument.CurrentController.ActiveSheet.DrawPage.Forms.getByIndex(0).getByName("Autoclose")
oBreak = oDocument.CurrentController.ActiveSheet.DrawPage.Forms.getByIndex(0).getByName("autoclose_exit")
oBreak.State = 0
While Time() < TimeValue(end_time)
if oBreak.State > 0 then
oButton.Label = "Autoclose disabled"
while(oBreak.State > 0)
wait(1000)
Wend
start_time = Time
end_time = TimeValue(start_time) + TimeValue(auto_close_time)
else
diff = TimeValue(end_time) - TimeValue(Time())
timer = ""
if(SECOND(diff) < 10) then
timer = "0"
endif
timer = timer + + SECOND(diff)
timer = MINUTE(diff) & ":" & timer
oButton.Label = "Autoclose in " + timer
Wait 1000
end if
Wend
oDocument.Store
oDocument.Close(1)
End Sub
i although tried:
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(oDocument, ".uno:Save", "", 0, Array())
oDocument.close
Windows 10 Libreoffice 7.4.2 and 7.4.1.2 tested
how can i save and close the document without get an crash report,
and without get closed other opened documents?
thanks a lot
help is aprricated