various cells need to have Font white when printing a page

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
6,094
Office Version
  1. 2024
Platform
  1. Windows
I am using the following code.

When looking at the page on the pc in 4 various cells the font is Black so the user can see its value.
However this isnt to be seen on the printed sheet hence why i would like the font to be white.

I added what i thought was correct & ive shown you below BUT it still got printed in Black.
I get no errors when i click the command button.

What did i do wrong please advise


Rich (BB code):
Private Sub PurchasedKey_Click()
  Dim sPath As String
  Dim strFileName As String
  Dim sh As Worksheet
  Dim wb As Workbook
 
    With ActiveSheet
    If .Range("Q1") = "" Then
      MsgBox "NO CODE SHOWN TO GENERATE PDF", vbCritical, "NO CODE ON SHEET TO CREATE PDF"
      Exit Sub
    End If
    
    If .Range("N1") = "M" Then
       strFileName = "C:\Users\there\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\" & .Range("B3").Value & " (SLS).pdf"
    Else
       strFileName = "C:\Users\there\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\" & .Range("B3").Value & ".pdf"
    End If
          
    If Dir(strFileName) = "" Then
      .Range("A1:K23").ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
       MsgBox "PDF FILE HAS NOW BEEN SAVED", vbInformation + vbOKOnly, "SAVED PDF FILE MESSAGE"
      
    With ActiveSheet
    ActiveWindow.SelectedSheets.PrintOut copies:=1 ' ALTERNATE THE COMMENT OUT WITH PRINTING & THE MSGBOX BELOW
    'MsgBox "PRINTING CURRENTLY COMMENTED OUT IN THE CODE", vbInformation, "PRINTING OFF WHILST TESTING CODE"
    .Range("E9").Font.Color = vbWhite
    .Range("E13").Font.Color = vbWhite
    .Range("E17").Font.Color = vbWhite
    .Range("E21").Font.Color = vbWhite
       
    Unload PrinterForm
    
    Set wb = Application.Workbooks.Open("C:\Users\there\Desktop\REMOTES ETC\DR\DR.xlsm")
        Worksheets("POSTAGE").Activate

    Call DISCOHYPERLINK
    
    End With
          
    Else
      'IF FILE IS PRESENT DO NOT ALLOW FILE TO BE OVERWRITTEN & TO SHOW MSGBOX
       MsgBox "CUSTOMERS FILE HAS ALLREADY BEEN SAVED", vbCritical + vbOKOnly, "FILE ALLREADY SAVED MESSAGE"
       
       Dim strFolder As String
       strFolder = "C:\Users\there\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\"
       ActiveWorkbook.FollowHyperlink Address:=strFolder, NewWindow:=True
       Unload PrinterForm
       
    End If
    Exit Sub
    
    End With

End Sub
 
What am I missing here ? The code seems to be sending it to the printer "BEFORE" the cells are being turned to white.
 
Upvote 0
I put the code in Red between these lines below but it made the cells text white on the page.
Was that correct BUT then need to add code to change it back ?


Rich (BB code):
    With ActiveSheet<br>    ActiveWindow.SelectedSheets.PrintOut copies:=1 ' ALTERNATE THE COMMENT OUT WITH PRINTING &amp; THE MSGBOX BELOW
 
Upvote 0
So why doesn't it look more like this:

Rich (BB code):
    With ActiveSheet
        .Range("E9").Font.Color = vbWhite
        .Range("E13").Font.Color = vbWhite
        .Range("E17").Font.Color = vbWhite
        .Range("E21").Font.Color = vbWhite
       
        ' Print Now
        ActiveWindow.SelectedSheets.PrintOut copies:=1
       
        .Range("E9").Font.Color = vbBlack
        .Range("E13").Font.Color = vbBlack
        .Range("E17").Font.Color = vbBlack
        .Range("E21").Font.Color = vbBlack
    End With
 
Upvote 0
Solution

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top