Difference between revisions of "Closing a document"
From Apache OpenOffice Wiki
(remove from Category:Tutorials if in Category:Basic:Tutorials) |
|||
Line 1: | Line 1: | ||
− | < | + | <source lang="oobas"> |
thisComponent.close(true) | thisComponent.close(true) | ||
− | </ | + | </source> |
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: | ||
− | < | + | <source 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 | ||
− | </ | + | </source> |
fnSave is defined [[saving a document]]. | fnSave is defined [[saving a document]]. | ||
Example of calling <tt>subclose</tt>: | Example of calling <tt>subclose</tt>: | ||
− | < | + | <source lang="oobas"> |
subClose(thisComponent) | subClose(thisComponent) | ||
− | </ | + | </source> |
{| border="1" | {| border="1" |
Revision as of 17:44, 10 July 2008
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)
Warning: | Do not use thisComponent.dispose it could crash OpenOffice.org. |