Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2008, 02:41 PM
Authorized User
 
Join Date: Mar 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Rood67
Default Selecting A Printer From Code

Hi. I think I got this piece of code from here. And it works... right up until a new printer is added, then because it's hard coded, it ceases to function properly until re-coded.

Private Sub Report_Load()

'Set the default printer to the Xth (indexed 0 to 5) printer, which is the PDF Document Writer
    Application.Printer = Nothing
    'Dim prtDefault As Printer
    Application.Printer = Application.Printers(0)
    'Set prtDefault = Application.Printer
    'Application.Printer = Nothing

What I want to do is to step through the collection of printers, search for the name, extract the index, set my code to point to that printer, which in this case is my PDF creator.

I'm thinking something like this, but I'm sure it's wrong, but it will give the general idea.

dim AP as Application.Printers
dim C as integer

AP.movefirst
AP.movelast

for c = 0 to AP.count
if AP.fields(1) = "PDF Creator Driver" then
Application.Printers(AP.fields(0))
exit for
end if
next C

I know that has gaping errors, but it'll let you see what I'm trying to figure out. Fortunately, I don't have to code to step through recordsets for what I need in Access. Unfortunately, this doesn't give me opportunity or time to learn how to do this.

Any help would be greatly appreciated,
Scott

Rood67
__________________
<b>Rood67</b>





Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i get vb printer.print code for a word doc choudhry.usman Word VBA 1 March 6th, 2008 10:46 PM
Need code to open the printer dialog screen donrafeal Access VBA 1 June 13th, 2006 01:35 PM
Selecting Printer for CRViewer BillsDanny Pro VB 6 3 April 2nd, 2006 08:41 PM
submitting printer specific code/text to a port dcarlile C# 1 December 8th, 2005 07:58 AM
Printing document from a form & selecting printer lguzman Access VBA 1 June 23rd, 2004 11:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.