473,503 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lebans ReportToPDF solution Help

Tom
Hi:

I'm using the Leban's ReportToPDF solution and have encountered a small
problem. I'm calling the code using the following:

Call ConvertReportToPDF(strReportName, , , True, True)

Where strReportname is the name of the report being printed.

I would like the Dialog box to be shown to allow the user to select a
path and file name (hence ShowSaveFileDialog =True).

I would also like to specify a default file name and path. I've tried
entering that in the 3rd parameter in the call statement, but it
appears as though if you set ShowSaveFileDialog = True, that overrides
whatever OutputPDFname is set to. It also appears that OutputPDFname
is limited to name only, not path and name.

I've tried modifying fFileDialog() to include the following lines when
setting up the clsDialog:
clsDialog.InitDir = PDFPath
clsDialog.FileName = PDFFileName

Where PDFPath and PDFFileName are both properties set in the calling
code. That works fine unless the user cancels the operation. Then it
proceeds to save the file anyway because it has a valid file name
courtesy of the default value.

So I added "clsDialog.CancelError = True" after the above lines hoping
that would catch the User Cancel and abort the whole operation.
However, the code appears not to check for the error that should be
raised.

Bottom line - I've about reached my depth here and could use some
pointers on how to solve this problem.

Thanks in advance.

Tom

Dec 27 '05 #1
5 4429
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you want you could just not use the ReportToPDF class and use the
CutePDF Writer as the "printer" destination. Get the software from this
site:

http://tinyurl.com/dejty

Once set up all you have to do is "print" the report to the "printer"
named "Cute PDF Writer." A PDF file will be created.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ7HGU4echKqOuFEgEQL+rgCg7pPdupgjV48nfKVQ6pyuDf MXbcwAn3M8
I6dsnrPBbOaJJ+3oe6ng/Kbc
=K1ru
-----END PGP SIGNATURE-----
Tom wrote:
Hi:

I'm using the Leban's ReportToPDF solution and have encountered a small
problem. I'm calling the code using the following:

Call ConvertReportToPDF(strReportName, , , True, True)

Where strReportname is the name of the report being printed.

I would like the Dialog box to be shown to allow the user to select a
path and file name (hence ShowSaveFileDialog =True).

I would also like to specify a default file name and path. I've tried
entering that in the 3rd parameter in the call statement, but it
appears as though if you set ShowSaveFileDialog = True, that overrides
whatever OutputPDFname is set to. It also appears that OutputPDFname
is limited to name only, not path and name.

I've tried modifying fFileDialog() to include the following lines when
setting up the clsDialog:
clsDialog.InitDir = PDFPath
clsDialog.FileName = PDFFileName

Where PDFPath and PDFFileName are both properties set in the calling
code. That works fine unless the user cancels the operation. Then it
proceeds to save the file anyway because it has a valid file name
courtesy of the default value.

So I added "clsDialog.CancelError = True" after the above lines hoping
that would catch the User Cancel and abort the whole operation.
However, the code appears not to check for the error that should be
raised.

Bottom line - I've about reached my depth here and could use some
pointers on how to solve this problem.

Dec 27 '05 #2
On 27 Dec 2005 10:18:16 -0800, "Tom" <rt*****@swbell.net> wrote:
Hi:

I'm using the Leban's ReportToPDF solution and have encountered a small
problem. I'm calling the code using the following:

Call ConvertReportToPDF(strReportName, , , True, True)

Where strReportname is the name of the report being printed.

I would like the Dialog box to be shown to allow the user to select a
path and file name (hence ShowSaveFileDialog =True).

I would also like to specify a default file name and path. I've tried
entering that in the 3rd parameter in the call statement, but it
appears as though if you set ShowSaveFileDialog = True, that overrides
whatever OutputPDFname is set to. It also appears that OutputPDFname
is limited to name only, not path and name.

I've tried modifying fFileDialog() to include the following lines when
setting up the clsDialog:
clsDialog.InitDir = PDFPath
clsDialog.FileName = PDFFileName

Where PDFPath and PDFFileName are both properties set in the calling
code. That works fine unless the user cancels the operation. Then it
proceeds to save the file anyway because it has a valid file name
courtesy of the default value.

So I added "clsDialog.CancelError = True" after the above lines hoping
that would catch the User Cancel and abort the whole operation.
However, the code appears not to check for the error that should be
raised.

Bottom line - I've about reached my depth here and could use some
pointers on how to solve this problem.

Thanks in advance.

Tom


I have been playing with this recently, looking at replacing Stephen Leban's ExportToMSWord to his new
ConvertReportToPDF in a particular application. (both excellent utilities Stephen).

I had a similar problem to yours and overcame it by adding an additional argument to the function ConvertReportToPDF
called DefaultPath.

Public Function ConvertReportToPDF( _
Optional RptName As String = "", _
Optional SnapshotName As String = "", _
Optional OutputPDFname As String = "", _
Optional ShowSaveFileDialog As Boolean = False, _
Optional StartPDFViewer As Boolean = True, _
Optional CompressionLevel As Long = 0, _
Optional PasswordOwner As String = "", _
Optional PasswordOpen As String = "", _
Optional PasswordRestrictions As Long = 0, _
Optional DefaultPath = "" _ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
) As Boolean

I then use GetOpenFileName to have the user select the destination path and filename for the PDF.

If the user cancels, GetOpenFileName will return "noFile" so I exit the procedure here without having to call
ConvertReportToPDF.

If a path and filename is returned, I call ConvertReportToPDF and send the path as the last argument and set the
ShowSaveFileDialog argument to false.

The following is a cut down version of the procedure I use which might give you the idea.
'==============================================
Dim strDefaultPath as String
Dim strRepName as String
Dim strFileName as String
Dim strPathAndFile as String

strRepName = "rptActionRequestPrintToFile"
strFileName = "ActionRequest_" & Format$(lngARNo, "0000")

If Len(strDefaultPath) = 0 Then
strPathAndFile = GetFilePathActionRequest(strFileName) '<<< returns path/filename or "noFile"
strDefaultPath = fGetDefaultPath(strPathAndFile) '<<< strips filename and leaves path only
Else
strPathAndFile = strDefaultPath & strFileName
End If

If strPathAndFile <> "noFile" Then
If ConvertReportToPDF(strRepName, , strFileName, False, False, , , , , strDefaultPath) = True Then '<<<<<<<<<
'success message
Else
'error message
End If
End If
'==============================================

In ConvertReportToPDF you will need to modify the following line -

If ShowSaveFileDialog = False Then
' let's decompress into same filename but change type to ".tmp"
' But first let's see if we were passed an output PDF file name
If Len(OutputPDFname & vbNullString) = 0 Then
sOutFile = Mid(strPathandFileName, 1, Len(strPathandFileName) - 3)
sOutFile = sOutFile & "PDF"
Else
'change this line from sOutFile = OutputPDFname to - '<<<<<<<<<<<<<<<<<<<<<
sOutFile = DefaultPath & OutputPDFname & ".PDF" '<<<<<<<<<<<<<<<<<<<<<<<
End If
Else
' Call File Save Dialog
sOutFile = fFileDialog()
If Len(sOutFile & vbNullString) = 0 Then
Exit Function
End If
End If

'==============================================
Function fGetDefaultPath(strIn As String) As String
'strips file name from strIn and returns path only
Dim x As Integer
Dim y As Integer

x = 1
Do Until x = 0
x = InStr(x, strIn, "\")
If x <> 0 Then y = x
If x <> 0 Then x = x + 1
Loop
fGetDefaultPath = Left(strIn, Len(strIn) - (Len(strIn) - y))
End Function
'==============================================
Wayne Gillespie
Gosford NSW Australia
Dec 28 '05 #3
Thanks for helping out Wayne!

WIthin the next one or two releases I will encapsulate the code and expose
all of the necessary props. The current function call signature is getting
way too large and unwieldy. The project is still in Beta and it shows.
:-)

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Wayne Gillespie" <be*****@NOhotmailSPAM.com.au> wrote in message
news:ta********************************@4ax.com...
On 27 Dec 2005 10:18:16 -0800, "Tom" <rt*****@swbell.net> wrote:
Hi:

I'm using the Leban's ReportToPDF solution and have encountered a small
problem. I'm calling the code using the following:

Call ConvertReportToPDF(strReportName, , , True, True)

Where strReportname is the name of the report being printed.

I would like the Dialog box to be shown to allow the user to select a
path and file name (hence ShowSaveFileDialog =True).

I would also like to specify a default file name and path. I've tried
entering that in the 3rd parameter in the call statement, but it
appears as though if you set ShowSaveFileDialog = True, that overrides
whatever OutputPDFname is set to. It also appears that OutputPDFname
is limited to name only, not path and name.

I've tried modifying fFileDialog() to include the following lines when
setting up the clsDialog:
clsDialog.InitDir = PDFPath
clsDialog.FileName = PDFFileName

Where PDFPath and PDFFileName are both properties set in the calling
code. That works fine unless the user cancels the operation. Then it
proceeds to save the file anyway because it has a valid file name
courtesy of the default value.

So I added "clsDialog.CancelError = True" after the above lines hoping
that would catch the User Cancel and abort the whole operation.
However, the code appears not to check for the error that should be
raised.

Bottom line - I've about reached my depth here and could use some
pointers on how to solve this problem.

Thanks in advance.

Tom


I have been playing with this recently, looking at replacing Stephen
Leban's ExportToMSWord to his new
ConvertReportToPDF in a particular application. (both excellent utilities
Stephen).

I had a similar problem to yours and overcame it by adding an additional
argument to the function ConvertReportToPDF
called DefaultPath.

Public Function ConvertReportToPDF( _
Optional RptName As String = "", _
Optional SnapshotName As String = "", _
Optional OutputPDFname As String = "", _
Optional ShowSaveFileDialog As Boolean = False, _
Optional StartPDFViewer As Boolean = True, _
Optional CompressionLevel As Long = 0, _
Optional PasswordOwner As String = "", _
Optional PasswordOpen As String = "", _
Optional PasswordRestrictions As Long = 0, _
Optional DefaultPath = "" _ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
) As Boolean

I then use GetOpenFileName to have the user select the destination path
and filename for the PDF.

If the user cancels, GetOpenFileName will return "noFile" so I exit the
procedure here without having to call
ConvertReportToPDF.

If a path and filename is returned, I call ConvertReportToPDF and send the
path as the last argument and set the
ShowSaveFileDialog argument to false.

The following is a cut down version of the procedure I use which might
give you the idea.
'==============================================
Dim strDefaultPath as String
Dim strRepName as String
Dim strFileName as String
Dim strPathAndFile as String

strRepName = "rptActionRequestPrintToFile"
strFileName = "ActionRequest_" & Format$(lngARNo, "0000")

If Len(strDefaultPath) = 0 Then
strPathAndFile = GetFilePathActionRequest(strFileName) '<<< returns
path/filename or "noFile"
strDefaultPath = fGetDefaultPath(strPathAndFile) '<<< strips filename
and leaves path only
Else
strPathAndFile = strDefaultPath & strFileName
End If

If strPathAndFile <> "noFile" Then
If ConvertReportToPDF(strRepName, , strFileName, False, False, , , , ,
strDefaultPath) = True Then '<<<<<<<<<
'success message
Else
'error message
End If
End If
'==============================================

In ConvertReportToPDF you will need to modify the following line -

If ShowSaveFileDialog = False Then
' let's decompress into same filename but change type to ".tmp"
' But first let's see if we were passed an output PDF file name
If Len(OutputPDFname & vbNullString) = 0 Then
sOutFile = Mid(strPathandFileName, 1, Len(strPathandFileName) - 3)
sOutFile = sOutFile & "PDF"
Else
'change this line from sOutFile = OutputPDFname to -
'<<<<<<<<<<<<<<<<<<<<<
sOutFile = DefaultPath & OutputPDFname & ".PDF"
'<<<<<<<<<<<<<<<<<<<<<<<
End If
Else
' Call File Save Dialog
sOutFile = fFileDialog()
If Len(sOutFile & vbNullString) = 0 Then
Exit Function
End If
End If

'==============================================
Function fGetDefaultPath(strIn As String) As String
'strips file name from strIn and returns path only
Dim x As Integer
Dim y As Integer

x = 1
Do Until x = 0
x = InStr(x, strIn, "\")
If x <> 0 Then y = x
If x <> 0 Then x = x + 1
Loop
fGetDefaultPath = Left(strIn, Len(strIn) - (Len(strIn) - y))
End Function
'==============================================
Wayne Gillespie
Gosford NSW Australia

Dec 28 '05 #4
Tom
Excellent - thanks for the pointers Wayne, I'll give it a try tomorrow
morning.

Also thanks for the original solution Stephen. It was wonderfully easy
(at least until I started messing with it!) and help tremendously with
my project.

Tom

Dec 28 '05 #5
Tom there is a new release coming shortly(hopefully the final BETA version)
and then the first production release should be available shortly
thereafter. I have received comments from several hundred users and have
incorporated the most common feature requests into the next release. And
yes, many users requested that I expose default path/filename props along
with the final output path/filename. I'm working on this now but honestly
will not have time to finish the code until after New Years.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Tom" <rt*****@swbell.net> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Excellent - thanks for the pointers Wayne, I'll give it a try tomorrow
morning.

Also thanks for the original solution Stephen. It was wonderfully easy
(at least until I started messing with it!) and help tremendously with
my project.

Tom

Dec 28 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
3036
by: DFS | last post by:
If you're listening, I want the middle of the calendar (showing 1 month) to open below the cursor position. It currently opens just to the right and below the cursor position. I hunted through...
1
1721
by: Dennis Hartmann | last post by:
Thank you Stephen Lebans! This solution implements easily... and it works well. I figured performance would suffer a little because the report is first saved as a snapshot then converted but,...
2
1619
by: penguin732901 | last post by:
Hi Steve, I hope you can help me with this. In Access 97, I'm getting the following error. "The formats that enable you to output data as a Microsoft Excel, rich-text format, MS-DOS text, or...
6
1748
by: MLH | last post by:
Method "ouput to" of object "IDoCmd" failed displayed as an Access 40204 error. I dropped a JPEG object into an unbound report - just a small jpg image in the middle of the page and tried to...
0
1338
by: sramsey | last post by:
I have been using Lebans ReportToPDF code for a couple months without problems. We recently changed the format of the invoice and now the first line of the detail section of my report is missing 2...
6
2300
by: ldn95887 | last post by:
I have been using Lebans ReportToPDF code for a couple months without problems. We recently changed the format of the invoice and now the first line of the detail section of my report is missing 2...
2
1788
by: J-P-W | last post by:
Hi, I'm using Stephen Lebans ReportTpPDF (thank you Stephen) and it's great. I've not changed the code at all, I invoke it using: Call ConvertReportToPDF(Me.rptName, vbNullString,...
2
2089
by: Scott McDaniel | last post by:
Stephen Lebans A2000SnapshotToPDFVer751 sample makes use of the dynapdf.dll file ... can I legally deploy this file along with my application, or do I need to purchase something from DynaForms? I...
7
3471
by: rquintal | last post by:
I could not find a good method to pass a where clause or openargs to a report named in a call to stephen Lebans' fine reportToPDF utility.l. Do you have a good method to pass a PK to the report...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.