Autonaming a PDF report?

G

Guest

Hiya,

I am making my PDF report just fine but I would like to autoname the report
and even the save location if I can.

I have done this in the past but for the life of me cannot remember exactly
how I did it.

I am currently using the: DoCmd.OpenReport stDocName, acNormal
with the stDocName being my specific PDF report with the PDF printer
defined.

I remember sticking my own file name in there somehow and it was easy to do.

I saw the other ways on here to do it but all our computers already have
Adobe Professional on it and it doens't have to be 100% user input free.

thanks
 
G

Guest

The one way that I found for doing this is to change the adobe properties so
that it does not prompt you for a file name or open up the document after
creation. It will then create the pdf and put it in the default location.
Once the printing is complete, I just go and rename the file to a different
location and name. I caution you that you need to put in a delay timer to
give adobe time to make the file. Here is the code for doing this:


Private Sub CMDPrint_Click()
Dim oldname As String
Dim newname As String
Dim existingfile As String
Dim inputdir
existingfile = Dir("C:\directory\" & Me!ernum & ".pdf")

' *** This is to delete the existing pdf file if it exists
Do While Len(existingfile) > 0
Kill "C:\dbpr\" & existingfile
existingfile = Dir
Loop

' *** Print the report, Report has adobe pdf as specific printer
DoCmd.OpenReport "rptstructurepdf"

' *** Delay for completion of adobe printing
WaitAwhile (10)

' *** File locations
oldname = "C:\Documents and Settings\ME\My Documents\rptstructurePDF.pdf" _
: newname = "C:\Directory\" & Me!ernum & ".pdf"

' *** function for moving and changing the file name
Name oldname As newname
End Sub


Here is the waitahile code that I save as a module

Sub WaitAwhile(seconds As Integer)
On Error GoTo wait_err
Dim tmp As Variant
tmp = Now
Call SysCmd(acSysCmdInitMeter, "Waiting " & seconds & " Seconds...", seconds)
Do While Now < tmp + (seconds / 24 / 60 / 60)
Call SysCmd(acSysCmdUpdateMeter, DateDiff("s", tmp, Now))
DoEvents
Loop
wait_res:
Call SysCmd(acSysCmdClearStatus)
Exit Sub
wait_err:
MsgBox Error & " " & Err.DESCRIPTION, 0, "WaitAwhile Error!"
Resume wait_res
End Sub

You can adjust your time depending on how fast it takes you to create the
pdfs.
I've used this for a couple of years and while it is primitive, it does work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top