关闭表单时如何完成循环(window)
How to finish a loop when closing form(window)
这应该很容易,但我找不到。
我试图做一个循环来每分钟保存一次表单记录。哪个有效,但是当我关闭表单时,宏会保留 运行 并最终 returns 一个不需要的错误,因为表单不再打开:
BASIC runtime error.
An exception occurred
Type: com.sun.star.lang.DisposedException
Message: Frame disposed.
这是我的宏
Sub Save_loop
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Do Until '???window is closed
dispatcher.executeDispatch(document, ".uno:RecSave", "", 0, Array())
wait 60000
Loop
End Sub
如果不返回此错误,我可以在 While/Until 上添加什么?
userForm_QueryClose() 事件应该有效
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
is_closed = 1
End Sub
Sub Save_loop
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Do Until '???window is closed
If (is_closed = 1) Then break
dispatcher.executeDispatch(document, ".uno:RecSave", "", 0, Array())
wait 60000
Loop
End Sub
这应该很容易,但我找不到。 我试图做一个循环来每分钟保存一次表单记录。哪个有效,但是当我关闭表单时,宏会保留 运行 并最终 returns 一个不需要的错误,因为表单不再打开:
BASIC runtime error.
An exception occurred
Type: com.sun.star.lang.DisposedException
Message: Frame disposed.
这是我的宏
Sub Save_loop
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Do Until '???window is closed
dispatcher.executeDispatch(document, ".uno:RecSave", "", 0, Array())
wait 60000
Loop
End Sub
如果不返回此错误,我可以在 While/Until 上添加什么?
userForm_QueryClose() 事件应该有效
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
is_closed = 1
End Sub
Sub Save_loop
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Do Until '???window is closed
If (is_closed = 1) Then break
dispatcher.executeDispatch(document, ".uno:RecSave", "", 0, Array())
wait 60000
Loop
End Sub