Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send report to a specific printer with VBA code? 1

Status
Not open for further replies.

steve728

Programmer
Mar 16, 2003
536
US
If I know what printers exist in my control panel how can I specifiy one of them with VBA code prior to a report printing?? Also, how can I also specifiy the default printer?

Thank you

Steve
 
See faq703-2533

While this is specifically designed for Adobe Writer and saving the reports as PDFs, all the code you need is there to do what you want.....

If you have questions, let me know.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
For those who need a bit more explanation, see below:

' This is the function of concern
Public Sub SaveReportAsPDF(strReportName As String, strPath As String)

Dim strOldDefault As String

' This string goes out and get the value for your "default" printer
strOldDefault = QueryKey("Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device")

' This string sets the default printer to a new value
SetKeyValue "Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", "Acrobat PDFWriter", REG_SZ

SetKeyValue "Software\Adobe\Acrobat PDFWriter", "PDFFilename", strPath, REG_SZ

SetKeyValue "Software\Adobe\Acrobat PDFWriter", "bExecViewer", 0, REG_SZ

DoCmd.OpenReport strReportName

' In this example, this sets the default back to what it was when this code started
SetKeyValue "Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", strOldDefault, REG_SZ

End Sub


=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top