jimrward
Well-known Member
- Joined
- Feb 24, 2003
- Messages
- 1,903
- Office Version
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- 2003 or older
- Platform
- Windows
i am using the following code for a beforeprint event in MSWORD 2000, which works fine until we make a corporate move to a higher version of MSWORD where beforeprint is properly catered for.
module 1
Dim appWord As New PrinterClass
Sub AutoExec()
Set appWord.appWord = Word.Application
End Sub
printerclass module
Public WithEvents appWord As Word.Application
Private Sub appWord_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
'
'****
' Get printer name, network will start with \\l
' look for bookmark in document, if it exists add flag, if not drop thru and print document
'****
'
Myprinter = ActivePrinter
If UCase(Left(Myprinter, 3)) = "\\L" Then
If ActiveDocument.Bookmarks.Exists("PrinterFlag") = True Then
DateTimeStamp = Now()
DateTimeStamp = Left(DateTimeStamp, Len(DateTimeStamp) - 3)
ActiveDocument.Bookmarks("PrinterFlag").Range.Text = DateTimeStamp
End If
End If
End Sub
The above code works fine from within word when manually controlled by a user, we also have a .NET application which creates bulk word documents and uses the WORD objects and prints using the following snippet to perform the print, however it does not trigger the printerclass method defined above
Private _wordMergedDocument As Word.DocumentClass
'Open the previously merged document and convert to PDF
_wordApplication = New Word.ApplicationClass
_wordApplication.Visible = True
_wordMergedDocument = _wordApplication.Documents.Open(_localAregDirectory.FullName & WORD_DOCUMENT)
' outgoingcorrespondence.doc
'Print a hardcopy of the file.
If printDocuments = True Then
_wordMergedDocument.PrintOut(BackGround:=False)
End If
so it would appear the .printout does its own thing
any ideas anyone
module 1
Dim appWord As New PrinterClass
Sub AutoExec()
Set appWord.appWord = Word.Application
End Sub
printerclass module
Public WithEvents appWord As Word.Application
Private Sub appWord_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
'
'****
' Get printer name, network will start with \\l
' look for bookmark in document, if it exists add flag, if not drop thru and print document
'****
'
Myprinter = ActivePrinter
If UCase(Left(Myprinter, 3)) = "\\L" Then
If ActiveDocument.Bookmarks.Exists("PrinterFlag") = True Then
DateTimeStamp = Now()
DateTimeStamp = Left(DateTimeStamp, Len(DateTimeStamp) - 3)
ActiveDocument.Bookmarks("PrinterFlag").Range.Text = DateTimeStamp
End If
End If
End Sub
The above code works fine from within word when manually controlled by a user, we also have a .NET application which creates bulk word documents and uses the WORD objects and prints using the following snippet to perform the print, however it does not trigger the printerclass method defined above
Private _wordMergedDocument As Word.DocumentClass
'Open the previously merged document and convert to PDF
_wordApplication = New Word.ApplicationClass
_wordApplication.Visible = True
_wordMergedDocument = _wordApplication.Documents.Open(_localAregDirectory.FullName & WORD_DOCUMENT)
' outgoingcorrespondence.doc
'Print a hardcopy of the file.
If printDocuments = True Then
_wordMergedDocument.PrintOut(BackGround:=False)
End If
so it would appear the .printout does its own thing
any ideas anyone