Difference between revisions of "Closing a document"
From Apache OpenOffice Wiki
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | < | + | <syntaxhighlight lang="oobas"> |
thisComponent.close(true) | thisComponent.close(true) | ||
− | </ | + | </syntaxhighlight > |
Please note that the parameter being passed is to do with what should happen if another process has vetoed closing the document or not and not whether the document is to be saved. | Please note that the parameter being passed is to do with what should happen if another process has vetoed closing the document or not and not whether the document is to be saved. | ||
So to be sure that a document gets saved before closing use something like: | So to be sure that a document gets saved before closing use something like: | ||
− | < | + | <syntaxhighlight lang="oobas"> |
sub subClose(oDoc) | sub subClose(oDoc) | ||
if fnSave(oDoc) then | if fnSave(oDoc) then | ||
Line 18: | Line 18: | ||
end if | end if | ||
end sub | end sub | ||
− | </ | + | </syntaxhighlight> |
fnSave is defined [[saving a document]]. | fnSave is defined [[saving a document]]. | ||
Example of calling <tt>subclose</tt>: | Example of calling <tt>subclose</tt>: | ||
− | < | + | <syntaxhighlight lang="oobas"> |
subClose(thisComponent) | subClose(thisComponent) | ||
− | </ | + | </syntaxhighlight> |
− | { | + | {{Warn|Do not use <tt>thisComponent.dispose</tt> it could crash {{AOo}}.}} |
− | + | ||
− | |Do not use <tt>thisComponent.dispose</tt> it could crash | + | |
− | + | ||
[[Category:Basic:Tutorials]] | [[Category:Basic:Tutorials]] |
Latest revision as of 14:37, 24 August 2022
thisComponent.close(true)
Please note that the parameter being passed is to do with what should happen if another process has vetoed closing the document or not and not whether the document is to be saved.
So to be sure that a document gets saved before closing use something like:
sub subClose(oDoc) if fnSave(oDoc) then oDoc.close(true) fnClose = true else if msgbox("Unable to save the file before closing." & chr(13) & _ "Close any way?", 4 + 32, "File not saved warning") = 6 then oDoc.close(true) end if end if end sub
fnSave is defined saving a document.
Example of calling subclose:
subClose(thisComponent)