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>
|