Consulting

Results 1 to 5 of 5

Thread: Question about running VBA macro automatically upon opening document

  1. #1

    Question about running VBA macro automatically upon opening document

    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

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,357
    Location
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Thank you SO much ! It worked !

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,357
    Location
    I know
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •