![]() |
|
|
|
#1
|
|||
|
|||
|
I have created a letter in Word. I inserted an "instruction" for a field via Design Mode/Rich Text. For example, "insert position title here". When the user types something in the field, the "instruction" disappears. I was wondering if there is anyway for the instruction that is not edited to not show up when the document is printed.
I'm new to using developer... please help. |
|
#2
|
|||
|
|||
|
The technical term for this is a "Rich Text Content Control." Delete all the prompt text except a single space and give the content control a title in the properties dialog.
|
|
#3
|
||||
|
||||
|
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 |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Developer Controls
|
darrenbilly | Word | 2 | 12-09-2014 07:50 AM |
| Forms Data Using Developer Tab | scbarton | PowerPoint | 1 | 03-15-2012 09:24 AM |
| Microsoft Outlook 2007 Tasks Question | kebbin | Outlook | 1 | 10-04-2011 12:02 AM |
| Developer Tab not showing | merago | Office | 1 | 11-16-2010 01:45 PM |
| Microsoft Word Easier Navigation Question | xxlegendxx | Word | 0 | 03-22-2009 07:44 PM |