Difference between revisions of "Printing a document"
From Apache OpenOffice Wiki
| Line 32: | Line 32: | ||
subprint(ThisComponent, 1, ,"1", "PrintExample.txt") | subprint(ThisComponent, 1, ,"1", "PrintExample.txt") | ||
</code> | </code> | ||
| + | |||
| + | [[Category:Basic:Tutorials]] | ||
| + | [[Category:Tutorials]] | ||
Revision as of 17:44, 16 May 2006
To print the current document without passing any arguments:
[oobas]
thisComponent.print(array())
A more generic print routine:
[oobas]
sub subPrint(oDoc, optional ncopies, optional bCollate, optional sPages, optional sFileName)
dim mPrintOptions()
if not isMissing(nCopies) then
subAddproperty(mPrintOptions(), "CopyCount", nCopies)
end if
if not isMissing(bCollate) then
subAddproperty(mPrintOptions(), "Collate", bCollate)
end if
if not isMissing(sPages) then
subAddproperty(mPrintOptions(), "Pages", sPages)
end if
if not isMissing(sFilename) then
subAddproperty(mPrintOptions(), "FileName", sFileName)
end if
oDoc.print(mPrintOptions())
end sub
This function calls subAddProperty which is defined in working with properties.
Example of calling this function:
[oobas]
subprint(ThisComponent, 1, ,"1", "PrintExample.txt")