开发者

Printing with excel and java or others

开发者 https://www.devze.com 2023-03-09 09:20 出处:网络
at the moment I am using Desktop.print() to print excel sheets. This looks quite stupid when you want to print one file 10 times. Excel opens up, prints, shutsdown and that 10 times.

at the moment I am using Desktop.print() to print excel sheets. This looks quite stupid when you want to print one file 10 times. Excel opens up, prints, shutsdown and that 10 times.

I don't care about multiplatform stuff, so a call the exec(excel.exe print-this 10-times); would be perfectly okay.

How ca开发者_开发问答n this be done? Maybe displaying the excel print dialog?


Try a simple macro like this one, just make sure you change the parameters to what you want it as though!

sub printThis()

Sheets("Sheet1").Activate '// Activate the sheet you want to print With ActiveSheet.PageSetup '// Change the page setup parameters .Orientation = xlLandscape '// xlLandscape or xlPortrait .Draft = False '// If true then any graphics aren't printed .PaperSize = xlPaperA4 '// Paper size .FitToPagesWide = 2 '// How wide you want it to be .FitToPagesTall = 1 '// How tall you want it to be End With

'// Now print the selected page however many times you like! ActiveWindow.SelectedSheets.PrintOut Copies:=10, Collate:=True

End sub

Here's an old reference to it on the MSDN library if you want to see all of the different parameters. http://msdn.microsoft.com/en-us/library/aa174261(v=office.11).aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消