automate save as PDF with Name

  • Thread starter chopper7898 via AccessMonster.com
  • Start date
C

chopper7898 via AccessMonster.com

I'm using 2007 and I have the PDF download from MS and it works.
My old database I used the code below to save as Snapshot and it worked great.

I would like to do the same but as PDF.

Can I modify the code to do that?
The code below will send the report to the designated folder and adds
information from the report for the file name.
It works really great in Snapshot, but now at work it's PDF they want.


Private Sub cmdSaveReport_Click()
Dim strReportName As String
Dim strcriteria As String
If NewRecord Then
MsgBox "This record contains no data. Please select a record to print or Save
this record.", vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "Daily Report"
strcriteria = "[AutoNo]= " & Me![AutoNo]
DoCmd.OpenReport strReportName, acViewPreview, , strcriteria
If MsgBox("Do you want to save the report to My Document\Akima\Daily Reports?
", vbYesNo + vbQuestion, "Save Report") = vbYes Then
strOutputName = "C:Akima\Daily Reports\Site" & " " & (Me.Site) & " CQC" & "
DR-" & (Me.ReportNo) & " " & (Me.Shift) & " " & _ Format(Me.Date, "mm-dd-yy")
& " " & (Me.DateDay) & ".snp"
DoCmd.OutputTo acOutputReport, strReportName, acFormatSNP, strOutputName,
True
End If
End If
End Sub
 
B

bcap

acFormatPDF instead of acFormatSNP.

Be aware that there is a bug in the Access 2007 PDF functionality: text
underlining disappears from the PDF output.

(in fact, every new feature in Access 2007 has some kind of bug in it).
 
C

chopper7898 via AccessMonster.com

That doesn't work, the preview window comes up and all that but there's no
report in the folder.
acFormatPDF instead of acFormatSNP.

Be aware that there is a bug in the Access 2007 PDF functionality: text
underlining disappears from the PDF output.

(in fact, every new feature in Access 2007 has some kind of bug in it).
I'm using 2007 and I have the PDF download from MS and it works.
My old database I used the code below to save as Snapshot and it worked
[quoted text clipped - 32 lines]
End If
End Sub
 
C

chopper7898 via AccessMonster.com

I just tried the last line of code by its self and it works for opening up a
save dialog window where you have to type in the name to save.

How would I redo the rest of the code so it automatically saves to the
directed folder with the infomation in the code for the file name.
That doesn't work, the preview window comes up and all that but there's no
report in the folder.
acFormatPDF instead of acFormatSNP.
[quoted text clipped - 8 lines]
 
B

bcap

Here's a (working) statement which does exactly that (I know it works
because it's used every day in a live application):

DoCmd.OutputTo acOutputReport, "rptDiaryOutput", acFormatPDF,
strOutputFile, False

Doesn't look very different to what you have, and if it doesn't work for you
maybe it's because you already have the report open in preview, which is not
something I've tried. Maybe you could try closing the preview before
outputting the PDF.

chopper7898 via AccessMonster.com said:
I just tried the last line of code by its self and it works for opening up
a
save dialog window where you have to type in the name to save.

How would I redo the rest of the code so it automatically saves to the
directed folder with the infomation in the code for the file name.
That doesn't work, the preview window comes up and all that but there's no
report in the folder.
acFormatPDF instead of acFormatSNP.
[quoted text clipped - 8 lines]
End If
End Sub
 
C

chopper7898 via AccessMonster.com

Still doesn't work, I've been trying a lot things, changing the code around
and stuff.

When I only change the .snp to .pdf at the end of strOutputName line, a file
with the require name will show up in the designated folder with a PDF icon,
but you can't open it.

And then when I change the acFormatSNP to acFormatPDF nothing shows up in the
designated folder.

I also tried it with out the preview opening. Still nothing.
Here's a (working) statement which does exactly that (I know it works
because it's used every day in a live application):

DoCmd.OutputTo acOutputReport, "rptDiaryOutput", acFormatPDF,
strOutputFile, False

Doesn't look very different to what you have, and if it doesn't work for you
maybe it's because you already have the report open in preview, which is not
something I've tried. Maybe you could try closing the preview before
outputting the PDF.
I just tried the last line of code by its self and it works for opening up
a
[quoted text clipped - 11 lines]
 

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