Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 19th, 2008, 02:41 PM
Authorized User
 
Join Date: Mar 2004
Location: Knoxville, TN, USA.
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>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:01 PM.


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