determine which printer was selected from the print dialog (1 Viewer)

supmktg

Registered User.
Local time
Yesterday, 23:30
Joined
Mar 25, 2002
Messages
360
This for an app being used in Access 2003. I'm trying to (sort of) automate naming a PDF report. After the user selects a printer from the print dialog, if the printer name is like "*PDF*" then I want to put the PDF file name in the clipboard so it can be quickly pasted in the file name of the PDF printer's save dialog.

Something like this:
Code:
Dim strSelectedPrinter as string

DoCmd.OpenReport "rpt1", acViewPreview
DoCmd.RunCommand acCmdPrint

strSelectedPrinter = [I]'determine selected printer name here[/I]

If strSelectedPrinter like "*PDF*" then
[I]'place report name in clipboard[/I]
End if

DoCmd.Close acReport, "rpt1"

The closest code that I can find is
Code:
Application.Printer.DeviceName
but that returns the name of the default printer, not the selected printer.

Any help is appreciated!
Thanks,
Sup
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 05:30
Joined
Sep 12, 2006
Messages
15,658
I think in access the printer is always the selected printer

to use a specific printer you set the selected printer to a different one, then afterwards, delete that printer to return to the default printer.

I am not sure you can actually interrogate the printer within access, but I assume there is a windows API to do it.
 

smig

Registered User.
Local time
Today, 07:30
Joined
Nov 25, 2009
Messages
2,209
There is no PDF support in Access2003.
Look for Stephan Lebans' PDF code. I use it for years and very happy with it.
 

supmktg

Registered User.
Local time
Yesterday, 23:30
Joined
Mar 25, 2002
Messages
360
Thanks Dave,

From all of my research , I think you're right. I n order to do what I wanted I needed to create my own custom print dialog form with a printers list. I grab the current default printer name, then change the default to the selected printer from my list. Then I get thenew default printer name. After the printfunction is completed, I reset the default printer to the old default. It's not optimul, but it does what I wanted.

Sup

Smig, Ive used Lebans PDF function. It does work great! In this case, getting the remote end user to deal with the 2 dlls was not going to work.
 

smig

Registered User.
Local time
Today, 07:30
Joined
Nov 25, 2009
Messages
2,209
Smig, Ive used Lebans PDF function. It does work great! In this case, getting the remote end user to deal with the 2 dlls was not going to work.

Create an installer for the users.
I use Inno-Setup. It's great and free
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 05:30
Joined
Sep 12, 2006
Messages
15,658
Thanks Dave,

From all of my research , I think you're right. I n order to do what I wanted I needed to create my own custom print dialog form with a printers list. I grab the current default printer name, then change the default to the selected printer from my list. Then I get thenew default printer name. After the printfunction is completed, I reset the default printer to the old default. It's not optimul, but it does what I wanted.

Sup

Smig, Ive used Lebans PDF function. It does work great! In this case, getting the remote end user to deal with the 2 dlls was not going to work.

bit in bold

not so much "not optimal" - it is actually the only way to do it. although you do not need to actively reset it.

effectively
set application.printer = "specific printer"
set application.printer = nothing

clears it, and returns to default. Note that printer names are Case Sensitive.


I missed the point about it being A2003, for the pdf. Smig has helped you solve this.
 

supmktg

Registered User.
Local time
Yesterday, 23:30
Joined
Mar 25, 2002
Messages
360
Smig,

I just downloaded Inno-Setup. Thanks for the tip!

Sup
 

Users who are viewing this thread

Top Bottom