ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Choose printout color or b/w using vba (https://www.excelbanter.com/excel-programming/334955-choose-printout-color-b-w-using-vba.html)

Jonsson[_46_]

Choose printout color or b/w using vba
 

Hi
I want to be able to choose whether printout is to be in black an
white or color.

I'm using the code below, but dont know how to set the option to colo
or b/w
Can someone lead me to the right track?

Function Print
Dim Svar As String
Dim i As Long
Svar = MsgBox("Do you want to print in color?", vbYesNo, "Print out")
If Svar = vbYes Then
ActiveSheet.Select

For i = 4 To 33
Rows(i).EntireRow.Hidden = Range("A" & i).Value = 0
Next i
ActiveSheet.Select
.BlackAndWhite = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

ActiveSheet.Select

For i = 4 To 33
Rows(i).EntireRow.Hidden = False
Next i

Range("A1").Select

Else
If Svar = vbNo Then
ActiveSheet.Select

For i = 4 To 33
Rows(i).EntireRow.Hidden = Range("A" & i).Value = 0
Next i
ActiveSheet.Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
.BlackAndWhite = True
ActiveSheet.Select
For i = 4 To 33
Rows(i).EntireRow.Hidden = False
Next i
Range("A1").Select
End If
End If
End Function


//Thoma

--
Jonsso
-----------------------------------------------------------------------
Jonsson's Profile: http://www.excelforum.com/member.php...nfo&userid=547
View this thread: http://www.excelforum.com/showthread.php?threadid=38841


Gareth[_6_]

Choose printout color or b/w using vba
 

Hi,

If you try recording a macro of changing the pagesetup to printing black
and white that gives you most of the syntax.

As it stands, your code was a bit repetitive -so I've trimmed it down a
little.

HTH,
Gareth

Function PrintWithColourCheck()

Dim i As Long

With ActiveSheet

'Hide rows where the first column is empty
'(that's what you're trying to do here right?)
For i = 4 To 33
If .Range("A" & i).Value = 0 Then _
.Rows(i).EntireRow.Hidden = True
Next i

.PageSetup.BlackAndWhite = _
MsgBox("Do you want to print in color?", _
vbYesNo, "Print out") = vbNo

.PrintOut Copies:=1, Collate:=True

'Tidy up
.PageSetup.BlackAndWhite = False
Rows("4:33").EntireRow.Hidden = False

End With

End Function



Jonsson wrote:
Hi
I want to be able to choose whether printout is to be in black and
white or color.

I'm using the code below, but dont know how to set the option to color
or b/w
Can someone lead me to the right track?

Function Print
Dim Svar As String
Dim i As Long
Svar = MsgBox("Do you want to print in color?", vbYesNo, "Print out")
If Svar = vbYes Then
ActiveSheet.Select

For i = 4 To 33
Rows(i).EntireRow.Hidden = Range("A" & i).Value = 0
Next i
ActiveSheet.Select
BlackAndWhite = False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

ActiveSheet.Select

For i = 4 To 33
Rows(i).EntireRow.Hidden = False
Next i

Range("A1").Select

Else
If Svar = vbNo Then
ActiveSheet.Select

For i = 4 To 33
Rows(i).EntireRow.Hidden = Range("A" & i).Value = 0
Next i
ActiveSheet.Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
BlackAndWhite = True
ActiveSheet.Select
For i = 4 To 33
Rows(i).EntireRow.Hidden = False
Next i
Range("A1").Select
End If
End If
End Function


//Thomas



Jonsson[_47_]

Choose printout color or b/w using vba
 

Fixed it by myself and works great!

//Thomas


--
Jonsson
------------------------------------------------------------------------
Jonsson's Profile: http://www.excelforum.com/member.php...fo&userid=5472
View this thread: http://www.excelforum.com/showthread...hreadid=388415



All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com