MSWORD 2000 beforeprint event

jimrward

Well-known Member
Joined
Feb 24, 2003
Messages
1,903
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
  8. 2003 or older
Platform
  1. 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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,225,502
Messages
6,185,349
Members
453,287
Latest member
Emeister

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top