Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Content control prompt
Is there a way to prevent the content control prompt (eg:"click here to enter
info") from printing when no info is entered? In the old legacy text box a gray box would show but if no text was entered in would not show up in the document |
#2
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Content control prompt
On Sat, 3 May 2008 06:48:00 -0700, DRob wrote:
Is there a way to prevent the content control prompt (eg:"click here to enter info") from printing when no info is entered? In the old legacy text box a gray box would show but if no text was entered in would not show up in the document There doesn't appear to be anything built in for this, but there are at least two different things you can do with a macro. The general idea is that you intercept the print command and either set the Hidden font attribute of the controls to true (if you want the controls to collapse) or change the font color to white (if you want to maintain the spacing), do the printing, and then undo the font changes. Since there are two printing commands, one for the menu item that shows the Print dialog and one for the toolbar button that prints immediately, you need two macros. Here are a pair that hide the controls that have no entries. If you want to maintain the spacing, replace "Hidden = True" with "Color = wdColorWhite" and replace Hidden = False" with "Color = wdColorAutomatic". Sub FilePrint() Dim myCC As ContentControl With ActiveDocument ' hide the controls that have default text For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = True End If Next Dialogs(wdDialogFilePrint).Show ' reverse the hiding For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = False End If Next End With End Sub Sub FilePrintDefault() Dim myCC As ContentControl With ActiveDocument ' hide the controls that have default text For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = True End If Next ActiveDocument.PrintOut Background:=False ' reverse the hiding For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = False End If Next End With End Sub See http://www.gmayor.com/installing_macro.htm if needed. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#3
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Content control prompt
That's brilliant, I never thought to approach it from the printing side of
the equation. I'm a bit of a novice with VBA, what do I need to do to have the macros run whenever the files or templates with content controls are used, do I have to activate the macro or can this be done automatically.? "Jay Freedman" wrote: On Sat, 3 May 2008 06:48:00 -0700, DRob wrote: Is there a way to prevent the content control prompt (eg:"click here to enter info") from printing when no info is entered? In the old legacy text box a gray box would show but if no text was entered in would not show up in the document There doesn't appear to be anything built in for this, but there are at least two different things you can do with a macro. The general idea is that you intercept the print command and either set the Hidden font attribute of the controls to true (if you want the controls to collapse) or change the font color to white (if you want to maintain the spacing), do the printing, and then undo the font changes. Since there are two printing commands, one for the menu item that shows the Print dialog and one for the toolbar button that prints immediately, you need two macros. Here are a pair that hide the controls that have no entries. If you want to maintain the spacing, replace "Hidden = True" with "Color = wdColorWhite" and replace Hidden = False" with "Color = wdColorAutomatic". Sub FilePrint() Dim myCC As ContentControl With ActiveDocument ' hide the controls that have default text For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = True End If Next Dialogs(wdDialogFilePrint).Show ' reverse the hiding For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = False End If Next End With End Sub Sub FilePrintDefault() Dim myCC As ContentControl With ActiveDocument ' hide the controls that have default text For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = True End If Next ActiveDocument.PrintOut Background:=False ' reverse the hiding For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = False End If Next End With End Sub See http://www.gmayor.com/installing_macro.htm if needed. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#4
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Content control prompt
"DRob" wrote: That's brilliant, I never thought to approach it from the printing side of the equation. I'm a bit of a novice with VBA, what do I need to do to have the macros run whenever the files or templates with content controls are used, do I have to activate the macro or can this be done automatically.? "Jay Freedman" wrote: On Sat, 3 May 2008 06:48:00 -0700, DRob wrote: Is there a way to prevent the content control prompt (eg:"click here to enter info") from printing when no info is entered? In the old legacy text box a gray box would show but if no text was entered in would not show up in the document There doesn't appear to be anything built in for this, but there are at least two different things you can do with a macro. The general idea is that you intercept the print command and either set the Hidden font attribute of the controls to true (if you want the controls to collapse) or change the font color to white (if you want to maintain the spacing), do the printing, and then undo the font changes. Since there are two printing commands, one for the menu item that shows the Print dialog and one for the toolbar button that prints immediately, you need two macros. Here are a pair that hide the controls that have no entries. If you want to maintain the spacing, replace "Hidden = True" with "Color = wdColorWhite" and replace Hidden = False" with "Color = wdColorAutomatic". Sub FilePrint() Dim myCC As ContentControl With ActiveDocument ' hide the controls that have default text For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = True End If Next Dialogs(wdDialogFilePrint).Show ' reverse the hiding For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = False End If Next End With End Sub Sub FilePrintDefault() Dim myCC As ContentControl With ActiveDocument ' hide the controls that have default text For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = True End If Next ActiveDocument.PrintOut Background:=False ' reverse the hiding For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = False End If Next End With End Sub See http://www.gmayor.com/installing_macro.htm if needed. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#5
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Content control prompt
Because of the specific names shown for the macros, they automatically intercept
and replace the built-in printing commands. Just place these macros in your Normal.dotm template, and they'll run whenever you print a document. (More at http://www.word.mvps.org/FAQs/Macros...tSavePrint.htm.) The For Each statement has the convenient behavior that if the collection is empty (that is, the document doesn't contain any content controls), then the loop exits immediately and does nothing. Only the Print statements will execute. That means you don't have to worry about it. :-) -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Tue, 6 May 2008 15:52:02 -0700, DRob wrote: "DRob" wrote: That's brilliant, I never thought to approach it from the printing side of the equation. I'm a bit of a novice with VBA, what do I need to do to have the macros run whenever the files or templates with content controls are used, do I have to activate the macro or can this be done automatically.? "Jay Freedman" wrote: On Sat, 3 May 2008 06:48:00 -0700, DRob wrote: Is there a way to prevent the content control prompt (eg:"click here to enter info") from printing when no info is entered? In the old legacy text box a gray box would show but if no text was entered in would not show up in the document There doesn't appear to be anything built in for this, but there are at least two different things you can do with a macro. The general idea is that you intercept the print command and either set the Hidden font attribute of the controls to true (if you want the controls to collapse) or change the font color to white (if you want to maintain the spacing), do the printing, and then undo the font changes. Since there are two printing commands, one for the menu item that shows the Print dialog and one for the toolbar button that prints immediately, you need two macros. Here are a pair that hide the controls that have no entries. If you want to maintain the spacing, replace "Hidden = True" with "Color = wdColorWhite" and replace Hidden = False" with "Color = wdColorAutomatic". Sub FilePrint() Dim myCC As ContentControl With ActiveDocument ' hide the controls that have default text For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = True End If Next Dialogs(wdDialogFilePrint).Show ' reverse the hiding For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = False End If Next End With End Sub Sub FilePrintDefault() Dim myCC As ContentControl With ActiveDocument ' hide the controls that have default text For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = True End If Next ActiveDocument.PrintOut Background:=False ' reverse the hiding For Each myCC In .ContentControls If myCC.ShowingPlaceholderText Then myCC.Range.Font.Hidden = False End If Next End With End Sub See http://www.gmayor.com/installing_macro.htm if needed. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Properties of combo box content control Word 2007 | Microsoft Word Help | |||
How do content control fields work? | Microsoft Word Help | |||
Entries in Drop-Down-Lists (content control) | Microsoft Word Help | |||
Content Control Titles Vanishing | Microsoft Word Help | |||
What is a Tag in the Content Control Properties dialog box? | Microsoft Word Help |