PDA

View Full Version : Form letter - print out on misuclance printers



Stofflggg
10-31-2017, 07:17 AM
Hello,

i would like to print each site from a formletter on the basis of an existing text ("xx_1_xx", "xx_2_xx", etc.) on a separate Printer.


As Example
On Page 1, 3 and 3 there is somewhere the Text "xx_1_xx" --> This 3 Pages should print out on Printer 1
On Page 4, 5 and 6 there is somewhere the Text "xx_2_xx" --> This 3 Pages should print out on Printer 2
and so on ...

With this script i read out the Printer from the document:



Dim i1 As Long, i2 As Long
Dim r As Range
Set r = ActiveDocument.Range
With r.Find
If .Execute("xx_") Then i1 = r.Start
r.Collapse
If .Execute("_xx") Then i2 = r.Start
End With
Set r = ActiveDocument.Range(i1, i2 + 3)
DruckAbteilung = Mid(r.Text, 4, Len(r.Text) - 6)

if DruckAbteilung = 1 then
ActivePrinter = "S01P01"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
end if
if DruckAbteilung = 2 then
ActivePrinter = "S02P02"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
end if

r.Delete




How can i now print out the pages on several Printers.

thanks a lot for help

regards,
Christoph