jasoncw
07-31-2007, 12:19 PM
I searched the site on this and found this thread:
http://www.vbaexpress.com/forum/showthread.php?t=6444
However, it does not appear to be working for me. Upon printing, I am intercepting the FilePrint and FilePrintDefault events, so that some items can be hidden before printing. My code looks like this:
Sub FilePrint()
'
' FilePrint Macro
' Prints the active document
'
If ThisDocument.ProtectionType = wdAllowOnlyFormFields Then _
ThisDocument.Unprotect
Call HideShapes
Dialogs(wdDialogFilePrint).Show
Call UnhideShapes
ThisDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End Sub
Sub FilePrintDefault()
'
' FilePrintDefault Macro
' Prints the active document using the current defaults
'
If ThisDocument.ProtectionType = wdAllowOnlyFormFields Then _
ThisDocument.Unprotect
Call HideShapes
ThisDocument.PrintOut
Call UnhideShapes
ThisDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End Sub
Sub HideShapes()
'hides command buttons and text boxes for printing
With ThisDocument
.Shapes(1).Visible = msoFalse
.Shapes(2).Visible = msoFalse
End With
End Sub
Sub UnhideShapes()
'unhides command buttons and text box
With ThisDocument
.Shapes(1).Visible = msoTrue
.Shapes(2).Visible = msoTrue
End With
End Sub
The form fields actually reset themselves before printing, so when the document is printed, only the default values are printing.
I'm sure this is a simple oversight on my part. Any help would be appreciated.
Jason
http://www.vbaexpress.com/forum/showthread.php?t=6444
However, it does not appear to be working for me. Upon printing, I am intercepting the FilePrint and FilePrintDefault events, so that some items can be hidden before printing. My code looks like this:
Sub FilePrint()
'
' FilePrint Macro
' Prints the active document
'
If ThisDocument.ProtectionType = wdAllowOnlyFormFields Then _
ThisDocument.Unprotect
Call HideShapes
Dialogs(wdDialogFilePrint).Show
Call UnhideShapes
ThisDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End Sub
Sub FilePrintDefault()
'
' FilePrintDefault Macro
' Prints the active document using the current defaults
'
If ThisDocument.ProtectionType = wdAllowOnlyFormFields Then _
ThisDocument.Unprotect
Call HideShapes
ThisDocument.PrintOut
Call UnhideShapes
ThisDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End Sub
Sub HideShapes()
'hides command buttons and text boxes for printing
With ThisDocument
.Shapes(1).Visible = msoFalse
.Shapes(2).Visible = msoFalse
End With
End Sub
Sub UnhideShapes()
'unhides command buttons and text box
With ThisDocument
.Shapes(1).Visible = msoTrue
.Shapes(2).Visible = msoTrue
End With
End Sub
The form fields actually reset themselves before printing, so when the document is printed, only the default values are printing.
I'm sure this is a simple oversight on my part. Any help would be appreciated.
Jason