[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1104
  • Last Modified:

VBA Script to print colored word text in black/white

I've got the following problem: I've got a word text where some words are colored. When I want to print the text it should be only black/white (or grayscale).

I think the easiest would be a VBA script which has the following features:
- Save document
- Mark everything
- Copy it in a temporary document
- Set auto as font color
- Print
- Copy the text from the temporary document back
- Delete temporary document

Can anybody post code which is able to do this?

Best regards and thanks a lot,
abfinfo

PS: I know it would be possible to set the printer to grayscale, but I don't want to do this because I only want a little script which is accessible by shortcut.
0
abfinfo
Asked:
abfinfo
  • 3
1 Solution
 
als315Commented:
You can try to do it without creating new document.
You can undo color changes after print:
Selection.WholeStory
Selection.Font.Color = wdColorAutomatic
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
        ManualDuplexPrint:=False, Collate:=False, Background:=True, PrintToFile:= _
        False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0
ActiveDocument.Undo 1
0
 
abfinfoAuthor Commented:
This customer has such a solution now but they complain sometimes the undo function undos too much (not only the auto colored text). Would it be a possibility to save the document before colorize it and set with this step a "checkpoint" to do a proper undo?

Or do you have an other idea what could be the problem with the undo?
0
 
GrahamSkanCommented:
You could try this:
Sub MonoPrint()
    Dim strFullname As String
    
    ActiveDocument.Save
    strFullname = ActiveDocument.FullName
    ActiveDocument.Range.Font.Color = wdColorBlack
    ActiveDocument.PrintOut
    ActiveDocument.Close wdDoNotSaveChanges
    Documents.Open strFullname
End Sub

Open in new window

0
 
abfinfoAuthor Commented:
Great idea :)
0
 
abfinfoAuthor Commented:
Thanks for your kind help! :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now