Here is the basics of a print macro that will print successive pages in turn. Use the "end of used area"-Cursor to print just the used area (bounded by blank rows and columns). Use the "gotoend"-Cursor to print the entire sheet (all the cells with entries plus, of course, the blank rows and columns). It prints the range from oCell (here, the top left cell on the page) to the lower right edge of oCursor.
Sub printpage
oSheets = ThisComponent.sheets
for j = 0 to oSheets.count() - 1
oSheet = oSheets.getbyindex(j)
oCell = oSheet.getcellbyposition(0,0)
oCursor = oSheet.createCursorbyrange(oCell)
oCursor.gotoEndOfUsedArea(true) ' This is a range
oCursor.gotoEnd 'This is a single cell
ThisComponent.getCurrentController.select(oCursor)
answer = msgbox("Do you want to print this sheet?",3,"Print sheet?")
if answer = 3 then'cancel
exit sub
elseif answer = 6 then'yes
oPrintArea(0).StartColumn = oCell.rangeaddress.StartColumn
oPrintArea(0).EndColumn = oCell.rangeaddress.EndColumn
oPrintArea(0).StartRow = oCursor.rangeaddress.StartRow
oPrintArea(0).EndRow = oCursor.rangeaddress.EndRow
oSheet.setPrintAreas(oPrintArea())
thisComponent.Print(Array())
end if
next
end sub
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment