How do i not print empy dropdown lists

M

Mangu68

I have a letter from which i can vary the content by changing my selections
from drop down lists. Not all drop down lists are necessarily used, yet they
still will print in the final document "Choose an Item". How do i stop word
2007 from printing non-selected drop down lists so they are invisible in the
final letter.
 
J

Jay Freedman

Mangu68 said:
I have a letter from which i can vary the content by changing my
selections from drop down lists. Not all drop down lists are
necessarily used, yet they still will print in the final document
"Choose an Item". How do i stop word 2007 from printing non-selected
drop down lists so they are invisible in the final letter.

I assume that you're referring to content controls rather than legacy
dropdown form fields, which don't show that text unless you specifically
create it.

Put these two macros in the template for the letter. The FilePrint macro
intercepts the Print command from the Office button and the Ctrl+P shortcut,
and the FilePrintDefault macro intercepts the Quick Print button on the
Quick Access Toolbar.

Sub FilePrint()
Dim oCC As ContentControl

' white out any control showing placeholder text
For Each oCC In ActiveDocument.ContentControls
If ((oCC.Type = wdContentControlDropdownList) _
Or (oCC.Type = wdContentControlComboBox)) _
And oCC.ShowingPlaceholderText Then
oCC.Range.Font.Color = wdColorWhite
End If
Next

Dialogs(wdDialogFilePrint).Show

' restore original color

For Each oCC In ActiveDocument.ContentControls
If ((oCC.Type = wdContentControlDropdownList) _
Or (oCC.Type = wdContentControlComboBox)) _
And oCC.ShowingPlaceholderText Then
oCC.Range.Font.Color = wdColorAutomatic
End If
Next
End Sub

Sub FilePrintDefault()
Dim oCC As ContentControl

' white out any control showing placeholder text
For Each oCC In ActiveDocument.ContentControls
If ((oCC.Type = wdContentControlDropdownList) _
Or (oCC.Type = wdContentControlComboBox)) _
And oCC.ShowingPlaceholderText Then
oCC.Range.Font.Color = wdColorWhite
End If
Next

ActiveDocument.PrintOut Background:=False

' restore original color

For Each oCC In ActiveDocument.ContentControls
If ((oCC.Type = wdContentControlDropdownList) _
Or (oCC.Type = wdContentControlComboBox)) _
And oCC.ShowingPlaceholderText Then
oCC.Range.Font.Color = wdColorAutomatic
End If
Next
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

Jennifer Biggs

These macros work great except for when the form is protected. Once it is protected it won't let you change the font color because it is protected. Is there a work around for this?

Thanks
 
J

Jay Freedman

The big workaround is this: don't use forms protection on documents that use
content controls. Forms protection is meant for "legacy" form fields, and it
doesn't play nicely with content controls in several different ways.

You can "protect" a content-control-containing document, so that nothing
outside the controls can be edited, as follows: Select the entire document
(Ctrl+A) or at least the part that is to be protected -- containing at least
one content control. Click the Group button to the right of the controls on
the Developer ribbon, and click Group on the dropdown menu.

Unlike forms protection, this will let you put the cursor anywhere in the
document; but if you try to edit or change the formatting outside the content
controls, nothing happens (there's a message in the status bar, which most
people never notice).

There are two or three drawbacks to this; if any of them are deal-breakers for
you, you'll have to use legacy form fields instead.

- There is no checkbox content control in Word 2007 (they were added in Word
2010). If you need checkboxes, look at
http://gregmaxey.mvps.org/Add_Toggle_Objects.htm for an alternative, or use a
dropdown content control instead.

- Unlike forms protection, grouping can't be assigned a password. Anyone can
ungroup the document and make changes anywhere.

- Unlike legacy forms, tabbing out of the last content control in the document
won't take you to the first control. This can be worked around with a macro if
you need it.

These macros work great except for when the form is protected. Once it is
protected it won't let you change the font color because it is protected. Is
there a work around for this?

Thanks
[snip]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top