AboutScottgem 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.
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