How do I assign a name to a PDF report via VBA

N

ND Pard

Thanks to the internet site:
http://msdn.microsoft.com/en-us/library/ee336132.aspx

I have the following subprocedure:

Private Sub Print_to_PDF_Click()
On Error Resume Next
Dim reportName As String

reportName = "HCBS CMgr Smmry Report"

DoCmd.OpenReport reportName, _
View:=acPreview, WindowMode:=acHidden
Set Reports(reportName).Printer = _
Application.Printers("CutePDF Printer")
DoCmd.OpenReport reportName, _
View:=acViewNormal
End Sub

This appears to be a good start; however, it stops and
waits for me to enter the name of the PDF report.

I want the name to come from a variable,
say: strMyPDFName

Then I'll send it to through a Loop to print approx
50 different PDFs, each with a unique name.

How can I modify the above code to pass the
PDF name to the PDF report?

Your help is needed and will be GREATLY appreciated.

Thanks in advance.
 
D

Daniel Pineault

M

Mark Andrews

Most pdf printer drivers require a registry setting to suppress the filename
prompt. I have mainly worked with win2pdf which is a great printer driver!

Most access 2003 and earlier users just use Lebans pdf routines to create
pdf files. Do a search I'm sure you will find them.

In access 2007 it has builtin pdf creation.

HTH,
Mark
 
N

ND Pard

Wheeewwww ....

Success tastes sweet!

I was able to send multiple documents to PDF files via VBA, but only after
much internet searching.

I created variables:

Dim MyPath as String
Dim MyFilter as String
Dim MyFileName as String

MyPath = Me.txt_PDF_Folder.Value

MyFileName = Me.cbx_Counties.Value

MyFilter = "[County_Name] = '" & Me.cbx_Counties.Value & "'"

DoCmd.OpenReport "MyReportName", _
acViewPreview, , MyFilter

DoCmd.OutputTo acOutputReport, "", acFormatPDF, _
MyPath & MyFileName, False

DoCmd.Close acReport, "MyReportName"


That's all it took ... and it works like a CHARM!!!!

Don't cha just hate it when they tell ya it can't be done :)
 

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