File Save dialog with Lebans ReportToPDF

B

Bob Howard

Hi,

I just started using the Lebans ReportToPDF (Access 2003) and it's working
fine except I noticed an interesting situation...

When I use the option to have the FileSaveDialog shown, and when the user
enters the file path / name of a PDF that already exists, no warning occurs
regarding overwrite, etc.

Is there a way to turn this on?

Or do I need to bring up the dialog myself, check for this condition, give
the user a chance to change his/her mind, and then pass the file path / name
to the ReportToPDF function telling it NOT to issue the dialog itself??

bob h
 
J

John Spencer

I inserted the following into the code for the ConvertReportToPDF function.
This is about 46 lines down into Stephen's code . That does not count blank
lines or comments. About 4 screen pages on my monitor

Else
' Call File Save Dialog
sOutFile = fFileDialog()
If Len(sOutFile & vbNullString) = 0 Then
Exit Function
End If

'============================================================================
' Begin added code
' Confirm overwrite of existing file
' John Spencer Code Addition
'============================================================================
If Len(Dir(sOutFile)) > 0 Then
If MsgBox("Replace " & Dir(sOutFile) & "?", _
vbOKCancel, "Overwrite") = vbCancel Then
Exit Function
End If
End If
'============================================================================
' --- end of added code ---------
'============================================================================

End If


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
B

Bob Howard

that did it! thanks so much... bob

John Spencer said:
I inserted the following into the code for the ConvertReportToPDF function.
This is about 46 lines down into Stephen's code . That does not count
blank lines or comments. About 4 screen pages on my monitor

Else
' Call File Save Dialog
sOutFile = fFileDialog()
If Len(sOutFile & vbNullString) = 0 Then
Exit Function
End If

'============================================================================
' Begin added code
' Confirm overwrite of existing file
' John Spencer Code Addition
'============================================================================
If Len(Dir(sOutFile)) > 0 Then
If MsgBox("Replace " & Dir(sOutFile) & "?", _
vbOKCancel, "Overwrite") = vbCancel Then
Exit Function
End If
End If
'============================================================================
' --- end of added code ---------
'============================================================================

End If


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
B

Bob Howard

John Spencer said:
I inserted the following into the code for the ConvertReportToPDF function.
This is about 46 lines down into Stephen's code . That does not count
blank lines or comments. About 4 screen pages on my monitor

Else
' Call File Save Dialog
sOutFile = fFileDialog()
If Len(sOutFile & vbNullString) = 0 Then
Exit Function
End If

'============================================================================
' Begin added code
' Confirm overwrite of existing file
' John Spencer Code Addition
'============================================================================
If Len(Dir(sOutFile)) > 0 Then
If MsgBox("Replace " & Dir(sOutFile) & "?", _
vbOKCancel, "Overwrite") = vbCancel Then
Exit Function
End If
End If
'============================================================================
' --- end of added code ---------
'============================================================================

End If


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

Did you ever play around with setting a default file name (one that I can
pass as a variable) that shows in the file dialog??

bob
 
J

John Spencer

Not using the class code Stephen has for requesting the save location. I've
done that with the code at
http://www.mvps.org/access/api/api0001.htm

I just downloaded Stephen's example database yesterday. That is something I
want to do, but have not yet seen if I can using Stephen's class code. If
not, I can do it using the above code in place of his call to fFileDialog.


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
B

Bob Howard

John Spencer said:
Not using the class code Stephen has for requesting the save location.
I've done that with the code at
http://www.mvps.org/access/api/api0001.htm

I just downloaded Stephen's example database yesterday. That is something
I want to do, but have not yet seen if I can using Stephen's class code.
If not, I can do it using the above code in place of his call to
fFileDialog.


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

Thanks, John. I'll also play with it a bit as I suspect we're heading down
the same path here...
I also note that Stephen uses the FileSave dialog ... I may also try using
the FileSaveAs dialog (it's slightly different...). Bob.
 
B

Bob Howard

Bob Howard said:
Thanks, John. I'll also play with it a bit as I suspect we're heading
down the same path here...
I also note that Stephen uses the FileSave dialog ... I may also try using
the FileSaveAs dialog (it's slightly different...). Bob.

Actually, elsewhere in my application I use the "ahtCommonFileOpenSave"
function by Ken Getz and Paul Litwin. Perhaps I'll modify Stephan's code to
use their function rather than calling his class (as done today). Their
functions accepts a default file name as the 6th (of 8)variable passed...
Bob
 
B

Bob Howard

John Spencer said:
Not using the class code Stephen has for requesting the save location.
I've done that with the code at
http://www.mvps.org/access/api/api0001.htm

I just downloaded Stephen's example database yesterday. That is something
I want to do, but have not yet seen if I can using Stephen's class code.
If not, I can do it using the above code in place of his call to
fFileDialog.


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

OK ... here's what I did...

In my program (before calling the Lebans code), I inserted a call the Getz /
Litwin function to get a filename. I pass variables to set a starting
directory (I used "My Documents"), set a title for the panel, various flags,
a default file name, the extension (pdf), and a few other things. It passes
back the chosen filename as a string (or an empty string if the user clicks
the Cancel button).

Unlesless the user clicked Cancel, I pass the result along to the Lebans
code to make the PDF. In the function call to the Lebans code, I set it so
it would not open the file save panel.

And since the Getz / Litwin code already checks for saving to a file that
already exists, I removed the extra code that you previously provided me
that I had inserted in the Lebans code (there was no need for it anymore).

This is now all working together just fine! And the Lebans code is back to
being unmodified (which I prefer).

bob h
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top