Have you ever changed the default printer from code?
I need to change the default printer and then change it back to the original printer.
Have you ever changed the default printer from code?
I need to change the default printer and then change it back to the original printer.
I use this to set the printer on a till that prints receipts.
VB Code:
Dim pPrinter As Printer For Each pPrinter In Printers If pPrinter.DeviceName = gstrReportPrinter Then ' Set printer as system default. Set Printer = pPrinter ' Stop looking for a printer. Exit For End If Next
The gstrReportPrinter is a string that holds the name of the printer I want to use.
I loop through the availablre printers and when I find the one I want set the printer object to use that one
Hope this Helps.
The Printer Object is supported in VB, but not (to my knowledge) in VBA, so Gary's code is not going to work for you.
Please use [Code]your code goes in here[/Code] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.
Creating A Wizard In VB.NET
Paging A Recordset
What is wrong with using On Error Resume Next
Good Article: Language Enhancements In Visual Basic 2010
Upgrading VB6 Code To VB.NET
Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked
What is wrong with this code? I want it to print to Acrobat and not the default printer.
Code:Option Explicit Private acc As Access.Application Private Sub Command1_Click() Dim pPrinter As Printer Dim view As Long Dim acdstl As String acdstl = "Acrobat Distiller" Set acc = New Access.Application For Each pPrinter In Printers If pPrinter.DeviceName = acdstl Then ' Set printer as system default. Set Printer = pPrinter ' Stop looking for a printer. Exit For End If Next acc.OpenCurrentDatabase ("C:\Documents and Settings\ihayse\Desktop\Monthly\Member Reports.mdb") acc.DoCmd.OpenReport "AB_Add-Drop by PCP Labels", acViewNormal 'acViewNormal means the report is just printed. acc.CloseCurrentDatabase Set acc = Nothing End Sub
I got it.........
If you got it, post it....it could, and probably will, help someone else.![]()
Please use [Code]your code goes in here[/Code] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.
Creating A Wizard In VB.NET
Paging A Recordset
What is wrong with using On Error Resume Next
Good Article: Language Enhancements In Visual Basic 2010
Upgrading VB6 Code To VB.NET
Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked
The code above will not print Access Reports. For some reason when it comes to print Access Reports they are going through the default printer. But if I say form1.printform it will send the form to the Distiller but not the Access Report.......
FYI
You can change the default printer for each and ever Access Report in the "Page Setup" of the report.....
Thanks!![]()
Please use [Code]your code goes in here[/Code] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.
Creating A Wizard In VB.NET
Paging A Recordset
What is wrong with using On Error Resume Next
Good Article: Language Enhancements In Visual Basic 2010
Upgrading VB6 Code To VB.NET
Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked