Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #19  
Old 01-12-2021, 04:08 PM
gmaxey gmaxey is offline VBA to set Content controls as non printing Windows 10 VBA to set Content controls as non printing Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Maybe a timing issue with the print spool. You might try:

Code:
Option Explicit
Public WithEvents oApp As Word.Application
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub oApp_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
Application.ScreenUpdating = False
MsgBox "!"
Dim CCtrl As ContentControl, i As Long
With Doc
  For Each CCtrl In .ContentControls
    With CCtrl
      If .Type <> wdContentControlPicture And .Type <> wdContentControlCheckBox Then
        If .Range.Text = .PlaceholderText Then
          i = i + 1
          .Range.Text = "_________________________"
        End If
      End If
    End With
  Next
  .PrintOut
  DoEvents
  Sleep 2000
  .Undo i
End With
Cancel = True
Application.ScreenUpdating = True
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to set Content controls as non printing Content Controls Sammie0Sue Word 6 11-06-2013 10:56 PM
VBA to set Content controls as non printing Rich Text Content Controls: Formatting? tinfanide Word VBA 8 03-04-2013 04:15 AM
Macro to link 2 content controls bortonj88 Word VBA 2 08-21-2012 06:24 AM
Content Controls Form Programming beachdog Word VBA 4 09-20-2011 10:26 AM
VBA to set Content controls as non printing Grouping Content Controls cksm4 Word VBA 2 03-01-2011 12:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft