Application.ActivePrinter port name in Excel ???
Application.ActivePrinter port name in Excel ???
(OP)
Hi
I am trying to get my code to select a PDF printer to generate PDF files. When I look at the properties of the printer in XP, the details are
Printer Name "Win2PDF"
Printer Port "PDFFILE:"
Therefore, my code for selecting the printer is
Application.ActivePrinter = "Win2PDF on PDFFILE:"
However, if I run this code, the following error is displayed
Run Time error '1004'
Method 'ActivePrinter' of object '_Application' failed
So, I then recordred a macro to select the printer and it came up with the following code
Application.ActivePrinter = "Win2PDF on NE04:"
So, now I'm confused. I need to run this Excel VBA project on three different computers and each one shows a different "NE" port name for the Win2PDF printer.
Finally, my question, How do I either detect which NE port name to use or force it to use the PDFFILE: port name ?
Any help will be appreciated.
PS. In case you haven't guessed, I'm quite new to VBA !
I am trying to get my code to select a PDF printer to generate PDF files. When I look at the properties of the printer in XP, the details are
Printer Name "Win2PDF"
Printer Port "PDFFILE:"
Therefore, my code for selecting the printer is
Application.ActivePrinter = "Win2PDF on PDFFILE:"
However, if I run this code, the following error is displayed
Run Time error '1004'
Method 'ActivePrinter' of object '_Application' failed
So, I then recordred a macro to select the printer and it came up with the following code
Application.ActivePrinter = "Win2PDF on NE04:"
So, now I'm confused. I need to run this Excel VBA project on three different computers and each one shows a different "NE" port name for the Win2PDF printer.
Finally, my question, How do I either detect which NE port name to use or force it to use the PDFFILE: port name ?
Any help will be appreciated.
PS. In case you haven't guessed, I'm quite new to VBA !
Steve Fairclough
I.T. Manager
RE: Application.ActivePrinter port name in Excel ???
Just a thought
--Paul
It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
RE: Application.ActivePrinter port name in Excel ???
Any ideas how to make the printer use the same NE port number on all three machines ?
Steve Fairclough
I.T. Manager
RE: Application.ActivePrinter port name in Excel ???
--Paul
It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
RE: Application.ActivePrinter port name in Excel ???
Function NetworkPrinter(ByVal myprinter As String)
On Error Resume Next
Dim NetWork As Variant
Dim X As Integer
'/// Define NetWork Array \\\
NetWork = Array("Ne00:", "Ne01:", "Ne02:", "Ne03:", "Ne04:", _
"Ne05:", "Ne06:", "Ne07:", "Ne08:", _
"Ne09:", "Ne10:", "Ne11:", "Ne12:", _
"Ne13:", "Ne14:", "Ne15:", "Ne16:", _
"LPT1:", "LPT2:", "File:", "SMC100:")
'Setup printer to Print
X = 0
TryAgain:
On Error Resume Next
'Printer
Application.ActivePrinter = myprinter & Prt_On & NetWork(X)
If Err.Number <> 0 And X < 16 Then
X = X + 1
GoTo TryAgain
ElseIf Err.Number <> 0 And X > 15 Then
GoTo PrtError
End If
On Error GoTo 0
NetworkPrinter = myprinter & Prt_On & NetWork(X)
errorExit:
Exit Function
PrtError:
'no printer found
NetworkPrinter = ""
Resume errorExit
End Function
RE: Application.ActivePrinter port name in Excel ???
When they start tele commuting, then it's gonna get really ugly
--Paul
It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...