Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application.ActivePrinter port name in Excel ??? 1

Status
Not open for further replies.

SteveFairclough

IS-IT--Management
Oct 31, 2001
50
GB
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 !

Steve Fairclough
I.T. Manager
 
Configure the printer ports on each machine to have the same configuration for the Win2PDF printer

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 ...
 
Thanks Paul, I would do that if I knew how to !!

Any ideas how to make the printer use the same NE port number on all three machines ?

Steve Fairclough
I.T. Manager
 
Go into the printer properties, and Add Port, or Configure Port

--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 ...
 
Here is some code i found for the same problem

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
 
That's definitely another way, that should work, but its also important to take control of your network, while you still can.

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 ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top