Difference between revisions of "Closing a document"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 1: Line 1:
<code>[oobas]
+
<source lang="oobas">
 
thisComponent.close(true)
 
thisComponent.close(true)
</code>
+
</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:  
  
<code>[oobas]
+
<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
</code>
+
</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>:  
  
<code>[oobas]
+
<source lang="oobas">
 
subClose(thisComponent)
 
subClose(thisComponent)
</code>
+
</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.
Personal tools