You are here:

Business Software/Modifying Lebans PDF Converter

Advertisement


Question
QUESTION: Hi there,  I am trying to use Lebans code for converting a report to PDF format.  In his sample database he has a list of reports and once you select one you can then click on the button to convert it.  I would like to add this button directly to my reports rather than selecting from a list.  However when I try to define the report name as the report that I am currently in I am getting an error saying that the Report name is invalid.  I did try looking this up, but I can't seem to find any threads with this specific problem.  Any help you can offer would be greatly appreciated.

Thank you,

Jennifer

(This is the part of the Command Button Code that I think I have to modify to reference the Report I am in, but as soon as I change 'lstRptName' I get an error.)

Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this example.
blRet = ConvertReportToPDF(Me.lstRptName, vbNullString, _
Me.lstRptName.Value & ".pdf", False, True, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to TRUE.

End Sub

ANSWER: First, you aren't really modifying Stephan's code, all you should be doing is supplying your own parameters.

In the code you show Me.lstRptName refers to a control on the form. In the sample, there is a listbox on the form where you select the report you want to convert. That is the control that is used. If you have a different control or way of supplying the report name you have to take that into account.

Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

---------- FOLLOW-UP ----------

QUESTION: That is my point.  I don't want to use the control that he has on his form, but I don't know how to change the code so that I can select a report by a different means.  I assume that I leave his module alone and that it is the command button code itself that can be modified to select one report and convert it to a pdf.  I don't need it to choose from a list.

Thank you,

Jennifer

Answer
OK, if you don't need to select from a list then just substitute the3 report name for Me.lstRptName surrounding the name in quotes. So if your report is named MyReport you use:

blRet = ConvertReportToPDF("MyReport", vbNullString, _
"MyReport" & ".pdf", False, True, 150, "", "", 0, 0, 0)

Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Business Software

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer some questions on a wide variety of business applications, including MS Office, Lotus Smartsuite, Visio, Notes and many others.

Experience

I have over 16 years of experience as an IT professional, supporting a wide variety of business applications.

©2012 About.com, a part of The New York Times Company. All rights reserved.