Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2015, 12:42 PM
smattern smattern is offline Microsoft Developer Question Windows 7 64bit Microsoft Developer Question Office 2007
Novice
Microsoft Developer Question
 
Join Date: Jan 2015
Posts: 1
smattern is on a distinguished road
Default Microsoft Developer Question

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.
Reply With Quote
  #2  
Old 01-21-2015, 10:08 PM
Charles Kenyon Charles Kenyon is offline Microsoft Developer Question Windows 7 64bit Microsoft Developer Question Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,116
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Attached Images
File Type: png 00 deleteme 0.png (2.3 KB, 19 views)
Reply With Quote
  #3  
Old 01-22-2015, 12:22 AM
gmayor's Avatar
gmayor gmayor is offline Microsoft Developer Question Windows 7 64bit Microsoft Developer Question Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
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 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
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Developer Question 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft