T
TomT
I am wondering if this can be done
We have a network printer installed which creates pdf files out of whatever is printed. Right now, users preview a report, and if they want to print to this pdf printer, they have to go File\Print then choose this printer from the list
I was hoping to put a button on a toolbar, which would 1) make sure they had this printer installed, 2) change the application default printer to it, 3) print the report, and 4) if necessary reset the default printer back to what it was
I have the code to see if the printer is there, and, as I understand it, set the default printer to the pdf printer. However running the code crashes Access, so I guess I'm doing something wrong, or perhaps this cannot be done
Here's the basic code to find out if the printer is there, and if it is, set the default printer
Public Function SetPDFPrinter() As Boolea
Dim prtDefaultName As Strin
Dim prtDefault As Printe
Dim prtLoop As Printe
Dim foundPDF As Boolea
'get the current default printe
Set prtDefaultOrig = Application.Printe
For Each prtLoop In Application.Printer
With prtLoo
If .DeviceName Like "*pdfFactory Pro" The
foundPDF = Tru
SetPDFPrinter = Tru
prtDefaultName = .DeviceNam
Set prtDefault = Application.Printers(prtDefaultName
Exit Fo
End I
End Wit
Next prtLoo
If foundPDF = True The
Set Application.Printer = prtDefaul
End I
End Functio
This is called from a simple sub, which is fired by a button on the toolbar (visible only when the report is being previewed
Public Sub PrintRpt(
If SetPDFPrinter = True The
DoCmd.RunCommand acCmdPrin
End I
End Su
Having been working with Access 97 for the last 7 years or so, I am not all that familiar with working with the new printer objects
If there's a better way to do this, I'd be grateful to hear it
Thanks
To
We have a network printer installed which creates pdf files out of whatever is printed. Right now, users preview a report, and if they want to print to this pdf printer, they have to go File\Print then choose this printer from the list
I was hoping to put a button on a toolbar, which would 1) make sure they had this printer installed, 2) change the application default printer to it, 3) print the report, and 4) if necessary reset the default printer back to what it was
I have the code to see if the printer is there, and, as I understand it, set the default printer to the pdf printer. However running the code crashes Access, so I guess I'm doing something wrong, or perhaps this cannot be done
Here's the basic code to find out if the printer is there, and if it is, set the default printer
Public Function SetPDFPrinter() As Boolea
Dim prtDefaultName As Strin
Dim prtDefault As Printe
Dim prtLoop As Printe
Dim foundPDF As Boolea
'get the current default printe
Set prtDefaultOrig = Application.Printe
For Each prtLoop In Application.Printer
With prtLoo
If .DeviceName Like "*pdfFactory Pro" The
foundPDF = Tru
SetPDFPrinter = Tru
prtDefaultName = .DeviceNam
Set prtDefault = Application.Printers(prtDefaultName
Exit Fo
End I
End Wit
Next prtLoo
If foundPDF = True The
Set Application.Printer = prtDefaul
End I
End Functio
This is called from a simple sub, which is fired by a button on the toolbar (visible only when the report is being previewed
Public Sub PrintRpt(
If SetPDFPrinter = True The
DoCmd.RunCommand acCmdPrin
End I
End Su
Having been working with Access 97 for the last 7 years or so, I am not all that familiar with working with the new printer objects
If there's a better way to do this, I'd be grateful to hear it
Thanks
To