I am using the following code to intercept the print event in word all works fine until you have more than one document open with the macro in then you get the message twice. Does anyone have any bright ideas how to stop this happening.
Thanks in advance (fingers crossed)
VB Code:
Private Sub App_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean) usrType = "HKEY_CURRENT_USER" location = regget(usrType & "\SOFTWARE\M\User Location") If Len(location) = 0 Then location = regget("HKEY_LOCAL_MACHINE\SOFTWARE\M\Station Location") End If If Left(LCase(location), 6) = "london" Then msg = "Only print the draft copy?" & vbCrLf & vbCrLf msg = msg & "Yes" & vbTab & "- Print only the draft copy." & vbCrLf msg = msg & "No" & vbTab & "- Print both copies." & vbCrLf msg = msg & "Cancel" & vbTab & "- Print using your word setting." clicked = MsgBox(msg, vbYesNoCancel) If clicked = vbYes Or clicked = vbNo Then 'Cancel the existing print job Cancel = True If clicked = vbNo Then ' Config the tray as needed for client copy Doc.PageSetup.FirstPageTray = wdPrinterLowerBin Doc.PageSetup.OtherPagesTray = wdPrinterUpperBin ' Print the client copy Doc.PrintOut Copies:=1 End If ' Config the trays as needed for the file copy Doc.PageSetup.FirstPageTray = wdPrinterLargeCapacityBin Doc.PageSetup.OtherPagesTray = wdPrinterLargeCapacityBin 'Print the file copy Doc.PrintOut Copies:=1 End If End If End Sub




Reply With Quote