Is there a way to use a BeforePrint Event in Word 2000 without creating a new Class Module? I'm needing to run a script automatically when the user invokes a print command. Word did not inherently have a BeforePrint event available without creating a new Class Module to create the DocumentsBeforePrint event.
"Public WithEvents MyWord As Word.Application
Public Sub MyWord_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
On Error Resume Next
If Options.BlueScreen = True Then
Day
End If
End Sub"
To make a long story short, I must have all word templates create "template independent documents", so I had to write a script that copies all the scripts from the template to every document that gets created off the template. When I added the syntax to copy the Class Module, McAfee Virus Scan sees it as a virus and deletes all the scripts from the template. Below is the script that causes McAfee to balk:
'This section copies the Module1 in the .dot to Module1 in the .doc; the Word Application Class module in the dot. to the doc; and the InstDlgBox module in the dot to the doc.
TemplateName = Application.ActiveDocument.AttachedTemplate.FullName
FileName = Application.ActiveDocument.FullName
Application.OrganizerCopy _
Source:=TemplateName, _
Destination:=FileName, _
Name:="Module1", _
Object:=wdOrganizerObjectProjectItems
Application.OrganizerCopy _
Source:=TemplateName, _
Destination:=FileName, _
Name:="WordApplication", _
Object:=wdOrganizerObjectProjectItems
'Comment out next next5 lines if Instruction Dialog Box not used
Application.OrganizerCopy _
Source:=TemplateName, _
Destination:=FileName, _
Name:="InstDlgBox", _
Object:=wdOrganizerObjectProjectItems
'This section copies all the Scripts from ThisDocument in the .dot to the new .doc.
Application.ActiveDocument.AttachedTemplate.VBProject.VBComponents.Item(1).Export "C:\ScriptFiles.sys"
"Public WithEvents MyWord As Word.Application
Public Sub MyWord_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
On Error Resume Next
If Options.BlueScreen = True Then
Day
End If
End Sub"
To make a long story short, I must have all word templates create "template independent documents", so I had to write a script that copies all the scripts from the template to every document that gets created off the template. When I added the syntax to copy the Class Module, McAfee Virus Scan sees it as a virus and deletes all the scripts from the template. Below is the script that causes McAfee to balk:
'This section copies the Module1 in the .dot to Module1 in the .doc; the Word Application Class module in the dot. to the doc; and the InstDlgBox module in the dot to the doc.
TemplateName = Application.ActiveDocument.AttachedTemplate.FullName
FileName = Application.ActiveDocument.FullName
Application.OrganizerCopy _
Source:=TemplateName, _
Destination:=FileName, _
Name:="Module1", _
Object:=wdOrganizerObjectProjectItems
Application.OrganizerCopy _
Source:=TemplateName, _
Destination:=FileName, _
Name:="WordApplication", _
Object:=wdOrganizerObjectProjectItems
'Comment out next next5 lines if Instruction Dialog Box not used
Application.OrganizerCopy _
Source:=TemplateName, _
Destination:=FileName, _
Name:="InstDlgBox", _
Object:=wdOrganizerObjectProjectItems
'This section copies all the Scripts from ThisDocument in the .dot to the new .doc.
Application.ActiveDocument.AttachedTemplate.VBProject.VBComponents.Item(1).Export "C:\ScriptFiles.sys"