在excel宏中更改打印机属性 [英] Change printer properties in excel macro
问题描述
在Excel宏/ Excel VBA中有什么办法可以将打印机属性更改为颜色而不是黑白吗?我想从宏中打印出颜色,但是每次退出excel时,都会将颜色设置为黑白。我希望宏每次运行时将颜色设置为彩色。这是我用来打印的代码:
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
如果不可能在vba中这样做
If it isn't possible to do this in vba I would be fine with an API solution as well.
推荐答案
而不是使用:
Workbooks("Book1.xlsm").Worksheets("Sheet3").PrintOut from:=1, To:=(i / 2) - 0.5
您可以使用:
Workbooks("Book1.xlsm").Worksheets("Sheet3").PrintOut
和你可以跳过:
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.
这篇关于在excel宏中更改打印机属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!