PDA

View Full Version : print to pdf (acrobat Distiller ) instead printer



zorka
03-26-2008, 05:44 AM
Hello,

Have a macro that works great for numbering word documents with consecutive numbers and printing them to the printer in batches. it works great in either Word 97 or word 2000.

Would like to change it to printe the consecutively numbered document to a PDF file with the number sequence appended to the file name.

Can anybody help with this modification? thx Zorka

exisitng code:

Sub NosSEIC()
'
' NosSEIC Macro
' Macro created 12/04/02 by Peter Janson
'
Dim Message As String, Title As String, Default As String, NumCopies As Long
Dim Rng1 As Range

' Set prompt.
Message = "Enter the number of copies that you want to print"
' Set title.
Title = "Print"
' Set default.
Default = "1"

' Display message, title, and default value.
NumCopies = Val(InputBox(Message, Title, Default))
SerialNumber = System.PrivateProfileString("C:\SetSEIC.Txt", _
"MacroSettings", "SerialNumber")

If SerialNumber = "" Then
SerialNumber = 1000
End If

Set Rng1 = ActiveDocument.Bookmarks("SerialNumber").Range
Counter = 0

While Counter < NumCopies
Rng1.Delete
Rng1.Text = Format(SerialNumber, "0000#")
ActiveDocument.PrintOut
SerialNumber = SerialNumber + 1
Counter = Counter + 1
Wend

'Save the next number back to the Settings.txt file ready for the next use.
System.PrivateProfileString("C:\SetSEIC.txt", "MacroSettings", _
"SerialNumber") = SerialNumber

'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
.Add Name:="SerialNumber", Range:=Rng1
End With

ActiveDocument.Save


End Sub

Nelviticus
03-27-2008, 05:16 AM
I don't know what control you have over file names with distiller but you could always re-name the file after printing it, like this:

Dim sPDFFileName As String
Dim sNewFileName As String
Dim iSerialNumber As Integer

' Find the current PDF file name
sPDFFileName = Replace(ActiveDocument.FullName, _
".docm", ".pdf")

' Set your index number here
iSerialNumber = 99

If Dir(sPDFFileName) <> "" Then
sNewFileName = Replace(sPDFFileName, ".pdf", _
Format(iSerialNumber, "0000#") & ".pdf")
Name sPDFFileName As sNewFileName
End If

Regards