PDA

View Full Version : Question about running VBA macro automatically upon opening document



Needhelp!!!
12-18-2012, 11:43 AM
Hi,
I am creating a form, and I need help with my VBA Code. (Code is below) I can't get it to work. I am an amateur at this, so please, any help is appreciated. I think the problem lies in between the "Private Sub Document_Open() and the End Sub. How do I make the transition from opening the document to telling the document not to print placeholders in content control when the document is printed??

Private Sub Document_Open()
End Sub
Sub FilePrint()
Dim cc As ContentControl
Dim col As Long
With ActiveDocument
' hide placeholders
For Each cc In .ContentControls
If cc.ShowingPlaceholderText Then
col = cc.Range.Font.Color
cc.Range.Font.Color = wdColorWhite
End If
Next
Dialogs(wdDialogFilePrint).Show
For Each cc In .ContentControls
If cc.ShowingPlaceholderText Then
cc.Range.Font.Color = col
End Sub

gmaxey
12-18-2012, 01:49 PM
See:
http://gregmaxey.mvps.org/word_tip_pages/content_controls_do_not_print_pht.html

Needhelp!!!
12-18-2012, 02:13 PM
Thank you SO much ! It worked !

gmaxey
12-18-2012, 02:15 PM
:hi: I know

Needhelp!!!
12-19-2012, 08:54 AM
Ok, Greg, now I have another question. My text in content control is not consistent. Some will show up as bold, others non bold. I am not sure why this is happening as I am making sure the text says non bold in the content control settings. Do you have any idea why this is happening?