INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

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!

E-mail*
Handle

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

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Member Feedback

"...this web site is a 'Godsend' for me. If I have a programming problem that I'm unable to solve, I'll get a sensible reply in no time. It's really great!..."

Geography

Where in the world do Tek-Tips members come from?

 Application.ActivePrinter port name in Excel ???

SteveFairclough (IS/IT--Management)
13 Jul 04 7:43
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

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

SteveFairclough (IS/IT--Management)
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

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

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

Start A New Thread

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

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

Promoting, selling, recruiting and student posting
are not allowed in the forums.
Posting Policies

LINK TO THIS FORUM!
(Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum)
TITLE: VBA Visual Basic for Applications (Microsoft) Forum at Tek-Tips
URL: http://www.tek-tips.com/threadminder.cfm?pid=707
DESCRIPTION: VBA Visual Basic for Applications (Microsoft) technical support forum and mutual help system for computer professionals. Selling and recruiting forbidden.

 

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