I'm currently developing reports using VB and a report tool (Crystal Reports) which is an Add-In to VB. Crystal Reports offers background colors such as Navy and Silver.
I decided it would be best to change the background color to white (from
silver) during the print job to save toner. However, getting the colors
back to their original state has been a trick for one reason. That is, not
all colors offered by Crystal Reports are available in VB while programming.
I need the report header background to be Navy and the header text to be
white. All other bacground should be silver. I have the code that turns
the colors to white and black within the PrintClicked command, and I'm almost
done with the code which turns it all back within the RefreshClicked
command:
For the Print Job:
Private Sub CRViewer1_PrintButtonClick
ed(UseDefa
ult As Boolean)
Dim crSections As CRAXDRT.Sections
Dim crSection As CRAXDRT.Section
Dim crTextObject As Object
Dim crReportObject As Object
Report.SelectPrinter Printer.DriverName, Printer.DeviceName, Printer.Port
Set crSections = Report.Sections
For Each crSection In crSections
crSection.BackColor = vbWhite
Report.Text8.TextColor = vbBlack
Next crSection
End Sub
Turning The Colors Back:
Private Sub CRViewer1_RefreshButtonCli
cked(UseDe
fault As Boolean)
Dim crSections As CRAXDRT.Sections
Dim crSection As CRAXDRT.Section
Dim crTextObject As Object
Dim crReportObject As Object
Font.Color
Report.SelectPrinter Printer.DriverName, Printer.DeviceName, Printer.Port
Set crSections = Report.Sections
For Each crSection In crSections
crSection.BackColor = vbsilver
Report.Section1.BackColor = vbNavy
Report.Text8.TextColor = vbWhite
Next crSection
End Sub
The problem here is that there is no such thing as 'vbSilver' or 'vbNavy'.
How can I get those colors? I was thinking I could create 'TextColor'
variables within the PrintClicked command and set them to the Navy and Silver objects of the header background and report background. This would be done previous to turning the backgrounds white. If that sounds good, can you tell me how the syntax is done and whether I can call these variables within the RefreshButtonClicked command when resetting the colors?
I'll take any suggestions for a different approach but I think this might be simplest. Can you edit the code above if my idea sounds good, thanks.
Here are the only VB colors available:
vbBlack
vbRed
vbGreen
vbYellow
vbBlue
vbMagenta
vbCyan
vbWhite