Lebans Convert to PDF and Access 2010

chrisvt

Registered User.
Local time
Today, 16:10
Joined
Apr 21, 2009
Messages
22
I've been successfully using the Lebans convert to pdf code in our Access 2003 databases. A few days ago we migrated to Access 2010 and while the code still works, every pdf that it creates is in landscape format, which is a problem because the report that I am converting needs to be in portrait format.

Is there a setting that I am missing or something that I should modify in the Lebans code to force the pdf to be portrait orientation? I'm worried that because Access 2010 doesn't have snapshot functionality (and the lebans code creates a temporary snapshot file) that this may be the root of the problem. In Access 2003, the code worked perfectly and created portrait oriented reports, so I'm at a loss about how to fix this.

Thanks in advance for any advice.
 
Look in to Docmd.OutputTo. Converting to pdf now comes with the newer versions of Access.
 
Thanks, vbaInet, I'll start looking into it. I was hoping to avoid that only because I need to export the reports to specific folders on our network (with the path coming from a field in one of my tables) and had the labens code setup to do that. it works perfect except for the landscape issue.
 
It is.

Additionally, the report preview shows things correctly in portrait orientation and the built-in convert to pdf functionality exports in portrait orientation.
 
In that case the source would be Lebhan's code. When you export to pdf does it look like Potrait? And have you tried printing to a different printer?
 
Is there already someone who solved this problem.

Lebans code Cmd reporttoPDF has problems in ms access 2010

It puts the report after convert to PDF automatic in landscape instead of Portrait and cut it partly



The advantage with the Lebans code you can export the file with a specified name, date, ex... With a macro i did not find out yet how to export it when you click a buttom to export it with a specified name?

Thanks for some positive response

Dummy
 
I never solved my issue but that was because I had to move on to some more urgent projects. I'll report back if I come up with a solution.
 
Thanks, i hope there is a Solution.

I just installed Access 2010 and now i running to this problem.
 
Switch over to the DoCmd.OutPutTo where you can specify to PDF (built-in for 2007 and 2010) and the file name as well.
 
Thanks Bob,

But I guess you mean in the VBA code not in the Macro.

I am not sure what you mean? Can you help me a bit

This is the code i have now:

Private Sub cmdReportToPDF_Click()
Dim stDocName As String
stDocName = "ArtikelReport"
DoCmd.OpenReport stDocName, acPreview, "Filter for Artikels"

Dim blRet As Boolean

blRet = ConvertReportToPDF("ArtikelReport", vbNullString, _
"\Artikel Tuft\Artikel\" & Me.ArtikelBezeichnung.Value & "-" & Me.Artikelnr.Value & "-" & Me.AIstand.Value & "-" & Datum.Value & ".pdf", False, True, 0, "", "", 0, 0)

End Sub
 
It would be something like this:

Code:
Private Sub cmdReportToPDF_Click()
Dim stDocName As String
Dim strPath As String
 
stDocName = "ArtikelReport"
 
strPath = "\Artikel Tuft\Artikel\" & Me.ArtikelBezeichnung.Value & "-" & Me.Artikelnr.Value & "-" & Me.AIstand.Value & "-" & Datum.Value & ".pdf"
 
DoCmd.OutputTo acOutputReport, stDocName, acFormatPdf, strPath
 
End Sub
 
Last edited:
Thanks, Bob.

Just to close my own thread, I was never able to get this to work in Access 2010 with the Lebans code so I re-coded everything using the built-in convert to PDF functionality. Everything is performing as it should and the reports are exporting in Portrait orientation.

For what it's worth, here is the code:

"Folder" is a field in one of my tables that contains the first part of the networked path for each project. Because we use that path for other purposes, I couldn't simply add the rest of the path to the field; instead I defined OutputPath, with OutputFile being the combination of the two.
Code:
Private Sub savetopdf()
On Error GoTo Err_savetopdf_Click
 
Dim stDocName As String
Dim filter As String
Dim OutputPath As String
Dim OutputFile As String
 
 
OutputPath = "\Archive\MonitoringReports\2010 Monitoring Report.pdf"
OutputFile = Folder + OutputPath
 
filter = "[StewID]=" & "'" & Me![StewID] & "'"
 
stDocName = "Monitoring Report All"
 
DoCmd.OpenReport stDocName, acPreview, , filter
DoCmd.OutputTo acReport, stDocName, acFormatPDF, OutputFile, True
 
Exit_savetopdf_Click:
Exit Sub
 
Err_savetopdf_Click:
MsgBox Err.Description
Resume Exit_savetopdf_Click
 
End Sub
 
Last edited by a moderator:
Hi Chris,
I read your post and i have a question regarding what you said here "export the reports to specific folders on our network (with the path coming from a field in one of my tables) and had the labens code setup to do that".
I also use Lebans code, and i also need the report to be saved at a specific folder (the path is defined in a field in some table). Lebans code automatically saves everything in "My documents", and i don't know how to change the destination folder to where i want the report to be saved.
Since you already have it working, i will really appreciate your help on this
 
Hi TravelingCat -

The key portions of the code that I posted are:

OutputPath = "\Archive\MonitoringReports\2010 Monitoring Report.pdf"
OutputFile = Folder + OutputPath

and

DoCmd.OutputTo acReport, stDocName, acFormatPDF, OutputFile, True

The table that is used to generate the report has a field in it called "Folder" which contains a path to a network drive. We have about 2000 records in that table and each path is different. For example, the Folder field for the Smith Farm project would read: \\ProjectDrive\Projects S\Smith Farm.

The OutputFile combines the data that is in the "Folder" field with the additional data that I've defined in OutputPath to create one long path.**

In the DoCmd I've told it to save the report to the path generated by OutputFile.

**-you could probably put the entire path in the "Folder" field. In our case, we use that field for other things, so I had to define the remainder of the path within the code.

Let me know if any of this is unclear.
 
Hi Chris, thank you for your detailed response.
But Lebans has its own variables for defining pathes, snapshots and what not - strPathandFileName, strPath.. i wonder how do they blend with your variable OutputFile? Do i use both them and yours?
And his DoCmd.OutputTo looks like this: DoCmd.OutputTo acOutputReport, RptName, "SnapshotFormat(*.snp)", strPathandFileName. Did you replace this line with yours? Also for OutputFormat i don't have "acFormatPDF" as an option.
Maybe you're using access 2007?.. :confused: (mine is 2003)
 
TravelingCat - my apologies. I thought you were looking to see how I solved this for 2010.

For 2003, I used the following code.

The StewID in the filter is the unique identifier for each project.

filepath (I renamed this OutputPath in the 2010 version) and OutputPDFname are as I explained above.

The rest came from the Lebans code.

Private Sub savetopdf_Click()
On Error GoTo Err_savetopdf_Click

Dim blRet As Boolean
Dim stDocName As String
Dim filter As String
Dim filepath As String
Dim OutputPDFname As String

filter = "[StewID]=" & "'" & Me![StewID] & "'"
stDocName = "Monitoring Report All"
filepath = "\Archive\MonitoringReports\2010 Monitoring Report.pdf"
OutputPDFname = Folder + filepath

DoCmd.OpenReport stDocName, acPreview, , filter
blRet = ConvertReportToPDF(stDocName, , OutputPDFname, , True)

Exit_savetopdf_Click:
Exit Sub

Err_savetopdf_Click:
MsgBox "PDF could not be created."
Resume Exit_savetopdf_Click

End Sub
 
Super! It finally works as i wanted for a long time now. Chris, thank you so much for returning to this subject and helping me out:)
 

Users who are viewing this thread

Back
Top Bottom