Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Application.ActivePrinter port name in Excel ???Helpful Member! 

SteveFairclough (IS/IT--Management) (OP)
13 Jul 04 7:43

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

PaulTEG (TechnicalUser)
13 Jul 04 15:20
Configure the printer ports on each machine to have the same configuration for the Win2PDF printer

Just a thought

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 ...

SteveFairclough (IS/IT--Management) (OP)
14 Jul 04 3:24
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

PaulTEG (TechnicalUser)
14 Jul 04 4:23
Go into the printer properties, and Add Port, or Configure Port


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 ...

Helpful Member!  Fatbelly (TechnicalUser)
16 Jul 04 14:26
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
  On Error Resume Next
  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)
  Exit Function
  'no printer found
  NetworkPrinter = ""
  Resume errorExit
End Function
PaulTEG (TechnicalUser)
16 Jul 04 22:09
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

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 ...

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close