UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> exporting pdf using different file names    
 
   
Loosh
post Nov 29 2007, 03:36 PM
Post #1

UtterAccess Addict
Posts: 215



Hi I have the following code which prints a pdf file of my report based on what county I have selected in my form:

CODE
Private Sub cmdPDFsingle_Click()
    On Error GoTo Err_Handler
    
    Dim strDocName As String
    strDocName = "Directory"

    Dim strCriteria As String
    strCriteria = "[County] = " & Me.lstCounty.Column(0) & ""
    
    Set Application.Printer = Nothing

    Application.Printer = Application.Printers("Adobe PDF")
    
    DoCmd.OpenReport strDocName, acViewNormal, , strCriteria
    
    Set Application.Printer = Nothing


Right now when I click on the command button the "Save As PDF" box pops up and "Directory.pdf" is the default save name. Is there a way where I could make the default save name the County Name followed by "Directory.pdf"

Example: Johnson_Directory.pdf

Thanks
Go to the top of the page
 
+
Dragyn
post Nov 29 2007, 04:07 PM
Post #2

UtterAccess Addict
Posts: 152
From: Omaha, NE



I'm not sure how much control you directly have over the Adobe PDF print driver. I previously was using it, and I handled file naming by letting the PDF Writer save out as a default name, then my code would rename it to my desired filename. A little tedious to code, to be honest.

Now I'm using (and would recommend) Lebans' ReportToPDF code. It gives you a single function call that will take any Report object and output as a PDF.

As an added bonus, it does NOT require any PDF Writing software on the PC to run his code.
Go to the top of the page
 
+
cew657
post Nov 29 2007, 04:12 PM
Post #3

UtterAccess Ruler
Posts: 1,078
From: United States - IA



In addition to what Dragyn suggested, I would try:

CODE
strDocName=Me.lstCounty.Column(0) & "_Directory"


HTH

Chad
Go to the top of the page
 
+
Loosh
post Nov 30 2007, 01:24 PM
Post #4

UtterAccess Addict
Posts: 215



Hi. Thanks for the replies. Chad I tried your code, but it wouldnt work. It needs the actual name of the report in order to open it "Directory". Maybe I could that in some export code?

Dragyn, thanks for pointing that code out to me. I think I'll just stick with the code i'm using it seems to work easily.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 02:43 AM