Click here to Skip to main content
16,012,611 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Good day all,

I could really use some help with this. I need to install a printer via VBA. The port will be a Local Port with the name of C:\My Documents for example. It will have a printer name of PS1. This will use a PS printer driver that is available to the user.

I've searched all over and i am getting frustrated. The closest thing that i saw that might do the trick as the AddPortEx API, but i just dont know how to start.

Thanks for any info.

UPDATE:
I am still doing some research and found that this could be done by using a batch script. Seems like the string would look something like this:

rundll32 printui.dll,PrintUIEntry /if /b "Test Printer" /c\\SERVER /f "%windir%\inf\ntprint.inf" /r "lpt1:" /m "AGFA-AccuSet v52.3"



How could i incorportate my requirements to this?

Port Name: C:\My Documents
Printer Name: PS1
Printer Driver: PS Printer

Thanks for your help.
Posted
Updated 7-Jan-12 11:52am
v2
Comments
Maciej Los 11-Jan-12 16:32pm    
Why VBA?
emrtnz 17-Jan-12 13:54pm    
hi losmac,

I'm working within an Office product, MS Project 2007. I am passing some variables through the code, such as the port name. I cannot place a folder at the root. It has to be in My Documents. We have different OSs and ofcourse, each has a unique username as part of the path. This is why i'm doing it in VBA. I can have the code create the folder for the port based on the users path information.

What else would you suggest? If you say batch script, then I would not mind going that route because im sure that i can create a batch script with VBA and then run it from VBA.

1 solution

Here[^] (Paul Carmen answer) you'll find a peace of code (working with vba) to remove all network printers and and define one.

Here[^] you'll find an answer how to display "Add printer" dialogbox with vba, using SendKeys function.

Here[^] is the ms social technet site, where you'll find more informations about "add printer"...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900