D
Dave Peterson
I think you should record a macro when you change printers to the Adobe PDF just
to make sure that you get the exact string (minus the NE stuff).
I saved this from a previous post.
When I do this kind of thing, I'll let the user decide what printer to use.
Maybe you can just show a dialog and let the user check/verify their printer
choices:
Application.Dialogs(xlDialogPrinterSetup).Show
But if you wanted to automate it, you could use something like:
Option Explicit
Sub testme()
Dim UseThisPrinter As String
Dim CurPrinter As String
'save the current printer
CurPrinter = Application.ActivePrinter
'make sure that the string is correct with your recorded macro
UseThisPrinter = GetPrinter(myPrinterName:="\\mrafp1\MRA-ADMINCP1 on Ne")
If UseThisPrinter = "" Then
MsgBox "Printer not found--what should happen"
Exit Sub '???
End If
'and change (temporarily to the network printer you want)
Application.ActivePrinter = UseThisPrinter
'your code to print
'change their printer back to what they like
Application.ActivePrinter = CurPrinter
End Sub
Function GetPrinter(myPrinterName As String) As String
Dim iCtr As Long
Dim myStr As String
Dim FoundIt As Boolean
Dim CurPrinter As String
CurPrinter = Application.ActivePrinter
FoundIt = False
For iCtr = 0 To 99
On Error Resume Next
myStr = myPrinterName & Format(iCtr, "00") & ":"
Application.ActivePrinter = myStr
If Err.Number = 0 Then
FoundIt = True
Exit For
Else
'keep looking
Err.Clear
End If
Next iCtr
On Error GoTo 0
Application.ActivePrinter = CurPrinter
If FoundIt = True Then
GetPrinter = myStr
Else
GetPrinter = ""
End If
End Function
to make sure that you get the exact string (minus the NE stuff).
I saved this from a previous post.
When I do this kind of thing, I'll let the user decide what printer to use.
Maybe you can just show a dialog and let the user check/verify their printer
choices:
Application.Dialogs(xlDialogPrinterSetup).Show
But if you wanted to automate it, you could use something like:
Option Explicit
Sub testme()
Dim UseThisPrinter As String
Dim CurPrinter As String
'save the current printer
CurPrinter = Application.ActivePrinter
'make sure that the string is correct with your recorded macro
UseThisPrinter = GetPrinter(myPrinterName:="\\mrafp1\MRA-ADMINCP1 on Ne")
If UseThisPrinter = "" Then
MsgBox "Printer not found--what should happen"
Exit Sub '???
End If
'and change (temporarily to the network printer you want)
Application.ActivePrinter = UseThisPrinter
'your code to print
'change their printer back to what they like
Application.ActivePrinter = CurPrinter
End Sub
Function GetPrinter(myPrinterName As String) As String
Dim iCtr As Long
Dim myStr As String
Dim FoundIt As Boolean
Dim CurPrinter As String
CurPrinter = Application.ActivePrinter
FoundIt = False
For iCtr = 0 To 99
On Error Resume Next
myStr = myPrinterName & Format(iCtr, "00") & ":"
Application.ActivePrinter = myStr
If Err.Number = 0 Then
FoundIt = True
Exit For
Else
'keep looking
Err.Clear
End If
Next iCtr
On Error GoTo 0
Application.ActivePrinter = CurPrinter
If FoundIt = True Then
GetPrinter = myStr
Else
GetPrinter = ""
End If
End Function