paul.hartland at fsmail.net
paul.hartland at fsmail.net
Wed Aug 8 09:30:09 CDT 2007
Rocky, To be honest I have only just started using the change default printer settings, and only used them in Visual Basic 6.0. We have Access 2002 I put the top half of my code in, and it seemed to work, thats why I sent it to the list. As for the report, I would assume it would just go into the open event. Paul Message Received: Aug 08 2007, 03:22 PM From: "Rocky Smolin at Beach Access Software" To: "'Access Developers discussion and problem solving'" Cc: Subject: Re: [AccessD] Changing Default Printer What version of Access has that Printer object? And that code would go into the report in the load or open event? The code I found that I posted yesterday works in A2K3, it's real short, but does it at the OS level, which is probably more sketchy than doing it inside Access itself. What to you think? Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of paul.hartland at fsmail.net Sent: Wednesday, August 08, 2007 1:40 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Changing Default Printer Importance: High Rocky, Not the neatest code in the world, but works for me: Dim prnPrinter As Printer Dim strDeviceName As String Dim bolFoundPrinter As Boolean strDeviceName = Printer.DeviceName ' Store current default printer bolFoundPrinter = False For Each prnPrinter In Printers If (prnPrinter.DeviceName = "NewPrinterName") Then Set Printer = prnPrinter bolFoundPrinter = True ' DO WHAT YOU WANT HERE TO PRINT Exit For End If Next ' Change back to original default printer For Each prnPrinter In Printers If (prnPrinter.DeviceName = strDeviceName) Then Set Printer = prnPrinter Exit For End If Next this is in VB6, so I assume should work in VBA for Access Message Received: Aug 07 2007, 08:49 PM From: "Rocky Smolin at Beach Access Software" To: "'Access Developers discussion and problem solving'" Cc: Subject: [AccessD] Changing Default Printer Dear List: Slightly different request for changing printers to the one I had a few day ago: Is there an easy way to save the current windows default printer and change to a user pre-selected printer (name stored in an local options table)? This is for a distributable app so there's no way to know what the installed printers are. The program needs to print to a PDF file. So the user has to have a PDF printer installed. They pre-select it through a combo box on a control panel loaded with all the installed printer names and the printer name is saved in a local table. The app then runs at night without user intervention triggered by windows scheduler. So when it runs these reports, I need it to change the windows default printer to whatever printer they select. And then change it back after I'm done printing. MTIA Rocky -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com Paul Hartland paul.hartland at fsmail.net 07730 523179 -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.11.8/941 - Release Date: 8/7/2007 4:06 PM -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com Paul Hartland paul.hartland at fsmail.net 07730 523179