Convert to pdf with Lebans - change default save location?

chrisvt

Registered User.
Local time
Today, 03:27
Joined
Apr 21, 2009
Messages
22
Hello-

I'm using the Lebans code to convert my report to pdf. http://www.lebans.com/reporttopdf.htm

It is working great, except that I was wondering if there was a way to change the default location where the pdf is saved. It is currently defaulting to save to my desktop and I'd prefer to save to a network drive.

I've pasted my code below. Do I need to add something? Is this even possible?

Private Sub printreport_Click()

Dim blret As Boolean
Dim stdocname As String
Dim Filter As String

Filter = "AutoID = forms!frmstwLSR!AutoID"
stdocname = "rptstwLSR"

DoCmd.OpenReport stdocname, acPreview, , Filter
blret = ConvertReportToPDF(stdocname, vbNullString, "x.pdf", True, True, 150, "", "", 0, 0, 0)

End Sub
 
If you look in the modReport2pdf in the sample database, you should see this:

Stephen Lebans said:
'blRet = ConvertUncompressedSnapshot(sFileName as String, sPDFFileName as String)
' Please note that sFileName must include a full valid path(folder) or it will default
' to your My Documents folder. For example "C:\MyPDFs\MonthlyReport.PDF"
 
Thanks, Bob. Where would that code go in relation to my previous code? After the first blRet line?
 
hhmm, it still seems to be defaulting to the desktop. Any idea what I am missing? Do I need to Dim something at the top?

Private Sub printreport_Click()

Dim blret As Boolean
Dim stdocname As String
Dim Filter As String

Filter = "AutoID = forms!frmstwLSR!AutoID"
stdocname = "rptstwLSR"

DoCmd.OpenReport stdocname, acPreview, , Filter
blret = ConvertReportToPDF(stdocname, vbNullString, "C:\pdfs\test.PDF", True, True, 150, "", "", 0, 0, 0)

End Sub
 
Change this:
blret = ConvertReportToPDF(stdocname, vbNullString, "C:\pdfs\test.PDF", True, True, 150, "", "", 0, 0, 0)


to this:

blret = ConvertReportToPDF(stdocname, , "C:\pdfs\test.PDF", , True)

You don't put vbNullString or "" in for missing parameters. Also, the compression (where you have 150 is not even a working feature). So, any parameters after the TRUE for opening the Acrobat Reader are not necessary and should not be there.
 

Users who are viewing this thread

Back
Top Bottom