Thanks guys, i actually got it to work and found a work around for the problem of windows choosing a different port (Ne04, Ne02, etc on each computer.
Public Function GetFullNetworkPrinterName() As String
' returns the full network printer name
' returns an empty string if the printer is not found
' e.g. GetFullNetworkPrinterName("printer_name")
' might return "printer_name on Ne04:"
Dim strCurrentPrinterName As String, strTempPrinterName As String, i As Long
strCurrentPrinterName = Application.ActivePrinter
i = 0
Do While i < 10
strTempPrinterName = "Adobe PDF on Ne" & Format(i, "00") & ":"
On Error Resume Next ' try to change to the network printer
Application.ActivePrinter = strTempPrinterName
On Error GoTo 0
If Application.ActivePrinter = strTempPrinterName Then
' the network printer was found
GetFullNetworkPrinterName = strTempPrinterName
i = 10 ' makes the loop end
End If
i = i + 1
Loop
' remove the line below if you want the function to change the active printer
' change back to the original printer
' Application.ActivePrinter = strCurrentPrinterName
'MsgBox (strTempPrinterName)
End Function
Dim PSFileName As String, PDFFileName As String, DistillerCall As String
Dim ReturnValue As Variant
'Define the path and filenames (can get the names from a cell, and add the path & extension):
PSFileName = "c:\" & target.Offset(0, -1).Value & " invoice.PS"
PDFFileName = "c:\" & target.Offset(0, -1).Value & " invoice.PDF"
'If the files already exist, delete them:
If Dir(PSFileName) <> "" Then Kill (PSFileName)
If Dir(PDFFileName) <> "" Then Kill (PDFFileName)
'The Sendkeys characters are the full path and filename, followed by the "Enter" key.
' These are buffered until the "print to file" screen appears:
SendKeys PSFileName & "{ENTER}", False
Application.ActivePrinter = GetFullNetworkPrinterName()
Worksheets("invoices").Range("a1:j29").PrintOut , PrintToFile:=True
'Add double quotes around the PS filename and PDF filename:
PSFileName = Chr(34) & PSFileName & Chr(34)
PDFFileName = Chr(34) & PDFFileName & Chr(34)
DistillerCall = "C:\Program Files\Adobe\Acrobat 6.0\Distillr\Acrodist.exe" & _
" /n /q /o" & PDFFileName & " " & PSFileName
'Call the Acrobat Distiller to distill the PS file. ReturnValue is zero
'if the application doesn't open correctly:
ReturnValue = Shell(DistillerCall, vbNormalFocus)
If ReturnValue = 0 Then MsgBox "Creation of " & PDFFileName & "failed."
Hope that helps everyone, and thanks to everyone that helped me out with any other issues.
Geoff