Change printer properties in excel macro

跟風遠走 提交于 2020-01-10 10:27:12

问题


Is there any way I can change printer properties to color rather than black and white in an Excel macro/Excel VBA? I would like to print in color from the macro but every time I exit excel it sets the color to black and white. I would like for the macro to set the color back to color every time I run it. This is the code I am using to print:

Workbooks("Book1.xlsm").Worksheets("Sheet3").PrintOut from:=1, To:=(i / 2) - 0.5

This prints every page effected by the macro but it does it in black and white. I have already tried this but it didn't change anything:

Workbooks("Book1.xlsm").Worksheets("Sheet3").PageSetup.BlackAndWhite = False

If it isn't possible to do this in vba I would be fine with an API solution as well.


回答1:


Rather than using:

Workbooks("Book1.xlsm").Worksheets("Sheet3").PrintOut from:=1, To:=(i / 2) - 0.5

You could just use:

Workbooks("Book1.xlsm").Worksheets("Sheet3").PrintOut

and you can skip:

Workbooks("Book1.xlsm").Worksheets("DoNotDelete").PageSetup.BlackAndWhite = False

Because it only changes the worksheet settings, not the print settings.

But as far as printing in color goes you are probably best off just creating a shortcut the same printer twice in the control panel and set one to default color and another to default black and white. This way you can specify color or black/white just by which printer you choose.



来源:https://stackoverflow.com/questions/24121426/change-printer-properties-in-excel-macro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!