Help finding Active printer "on Ne02"

Hlatigo

Well-known Member
Joined
Jun 3, 2002
Messages
677
Morning all!

I have excel printing some sheets to pdf and it works fine on my PC. WHen someone else tries to print it wont work because they arent on "Adobe PDF on Ne02:"...they maybe on Ne03 or Ne08 or ne05...you get my point.

I saw code on here before as to how to find the proper "port" but after a bit of searching, i cant find it again. anyone have an idea?

thanks in advance!



Code:
 Application.ActivePrinter = "Adobe PDF on Ne02:"
            ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
            "Adobe PDF on Ne02:"
 
Thank you, westconn1.
But there remains a serious problem.
Your sample contains a hardcoded "on", but it should be localized. My program should work on different computers, not English only.
Has anybody an idea of getting a correct text between printer name and NExx?
Maris
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
use a language converted string
or return the value from the string activeprinter

Code:
myon = ActivePrinter
pos = InStrRev(myon, " ")
pos1 = InStrRev(myon, " ", pos - 1) + 1
myon = Mid(myon, pos1, pos - pos1)
use the value from that like

activeprinter = prn & " " & myon & " " & Mid(regvalue, InStr(regvalue, ",") + 1)
in my english version myon returns the word "on", but it should return a single word value in any language, assuming that any language would use a single word representing on, which may be an invalid assumption
 
Upvote 0
Thank you, I used your advice.
However strange - why MS chose such an idiotic printer identification?
 
Upvote 0
also strange in word you can set printer without port, but in word, if changed in code always changes windows default printer as well
 
Upvote 0
Code:
WriteRegistry HKEY_CURRENT_USER, _
"Software\Adobe\Acrobat PDFWriter\", _
"PDFFileName", _
"C:\Printout.pdf"
 
Application.ActivePrinter = "Adobe PDF on Ne02:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Adobe PDF on Ne02:"

Would the above code help me set the file name for a PDF if I print from Excel using the following code:

Code:
ActiveWorkbook.Sheets("Report").Select
Application.ActivePrinter = "Adobe PDF on Ne04:"
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "Adobe PDF on Ne04:", Collate:=True

I need to name the PDF printed to something specific like:

Code:
Dim ReportDate, SaveName As String, Path As String
ReportDate = ActiveWorkbook.Sheets("Date Select").Range("E9").Value 'Reporting Date
SaveName = "DPR" & ReportDate & ".pdf" 'File Name
Path = ActiveWorkbook.Sheets("Date Select").Range("E15").Value & ReportDate & "\" 'Destination

Thanks
 
Upvote 0
i assume that would set the next filename to be saved by the pdf printer driver, but i do not know if acrobat driver can be set to auto (no user dialog)
 
Upvote 0
hi Wynanbez,

Not sure if you were ever able to get your code. I found some code on the internet that may do what you are asking.

If interested let me know...and i can check to see if this will help you
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,824
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top