Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.pagelayout
DRob DRob is offline
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.word.pagelayout
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default 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

' print
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

' print
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   Report Post  
Posted to microsoft.public.word.pagelayout
DRob DRob is offline
external usenet poster
 
Posts: 3
Default 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

' print
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

' print
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   Report Post  
Posted to microsoft.public.word.pagelayout
DRob DRob is offline
external usenet poster
 
Posts: 3
Default 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

' print
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

' print
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   Report Post  
Posted to microsoft.public.word.pagelayout
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default 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

' print
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

' print
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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Properties of combo box content control Word 2007 José Spanjaard Microsoft Word Help 3 February 13th 08 05:39 PM
How do content control fields work? piersonal Microsoft Word Help 14 January 17th 08 10:45 PM
Entries in Drop-Down-Lists (content control) gohlensc Microsoft Word Help 0 November 20th 07 03:45 AM
Content Control Titles Vanishing jwwegner Microsoft Word Help 1 March 24th 07 01:50 AM
What is a Tag in the Content Control Properties dialog box? cmc Microsoft Word Help 1 March 17th 07 12:26 AM


All times are GMT +1. The time now is 12:09 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"