View Single Post
 
Old 01-22-2015, 12:22 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You can print the document without field placeholder text showing by using a macro to hide it, though that creates other problems, not least of which is that you cannot force users to run the macros. However, if that is not an issue, save the document as macro enabled and add the following code.

The macro creates a temporary character style (I have used a name which should not exist in the document) which it applies to any content control displaying the placeholder text. The style is then set to hidden font, which hides the content control. The document is printed, and the style deleted, which removes it from the content controls, thus re-displaying them. The style is then removed from the document.

The macro intercepts the FilePrintDefault command which you can add to the QAT (Quick Access Toolbar) of the document.

Code:
Sub FilePrintDefault()
Dim oDoc As Document
Dim oCC As ContentControl
Dim oStyle As Style
Dim bFound As Boolean
    For Each oStyle In ActiveDocument.Styles
        If oStyle.NameLocal = "CC_Temp_Style" Then
            bFound = True
            Exit For
        End If
    Next oStyle
    If Not bFound Then
        Set oStyle = ActiveDocument.Styles.Add("CC_Temp_Style", wdStyleTypeCharacter)
    End If
    oStyle.Font.Hidden = True
    For Each oCC In ActiveDocument.ContentControls
        If Trim(oCC.Range.Text) = oCC.PlaceholderText Then
            oCC.Range.Style = "CC_Temp_Style"
        End If
    Next oCC
    DoEvents
    ActiveDocument.PrintOut
    oStyle.Delete
lbl_Exit:
    Set oDoc = Nothing
    Set oStyle = Nothing
    Set oCC = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote