ADawn
asked on
Common Dialog Issue(s) .ShowSave
Hello All,
I'm using MS Access 97. Here's my Function code. I need to save the file (DS.rtf) to a default directory.
I can't force the saved file to the default directory "MY Documents" unless I use the .ShowSave method
(which I don't want to use). For some reason, if I comment-out the .ShowSave part, the file is saved
in my app path directory. I need the file saved to the default directory.
Next, for you (ACCESS) guys, is there a way to hide the dialog box that appears telling you that the file is being outputed (Printed) when this function runs? There is a CANCEL button that I don't want a user to hit.
I originally posted this question on the MS Access area, but no one knew the answers - I thought you could help!
************************** ********** *****
Function AutoEmailRecipients_SaveAs MViewDRRTF ()
On Error GoTo Export_Err
Dim oCmnDlg As CommonDialog
Dim strFormat As String
Dim strFileName As String
Set oCmnDlg = Forms!frm_EmailDailyToReci pients!Com monDialog_ Email.Obje ct
With oCmnDlg
.FileName = "DS.rtf"
' Prompt the user if the file already exists.
.Flags = cdlOFNHideReadOnly
' Determine if the cancel button was pressed.
.CancelError = True
.Filter = _
"Rich Text Format (*.rtf)|*.rtf"
.FilterIndex = 2
' Default the initial directory to "C:\My Documents".
.InitDir = "C:\My Documents" 'Windows\Temp"
'.ShowSave
' Determine what file type was selected; then save the
' file in that format.
strFormat = acFormatRTF
strFileName = .FileName
DoCmd.OutPutTo acOutputReport, "rptEmail_To_Recipients_DR ", _
strFormat, strFileName
End With
Exit Function
Export_Exit:
Exit Function
Export_Err:
' Check to see if the cancel button was pressed.
If Err.Number = 32755 Then
Resume Export_Exit
Else: MsgBox "Action has been canceled.", vbOKOnly, DSVer
End If
Resume Export_Exit
End Function
************************** ***
Thanks,
ADawn
I'm using MS Access 97. Here's my Function code. I need to save the file (DS.rtf) to a default directory.
I can't force the saved file to the default directory "MY Documents" unless I use the .ShowSave method
(which I don't want to use). For some reason, if I comment-out the .ShowSave part, the file is saved
in my app path directory. I need the file saved to the default directory.
Next, for you (ACCESS) guys, is there a way to hide the dialog box that appears telling you that the file is being outputed (Printed) when this function runs? There is a CANCEL button that I don't want a user to hit.
I originally posted this question on the MS Access area, but no one knew the answers - I thought you could help!
**************************
Function AutoEmailRecipients_SaveAs
On Error GoTo Export_Err
Dim oCmnDlg As CommonDialog
Dim strFormat As String
Dim strFileName As String
Set oCmnDlg = Forms!frm_EmailDailyToReci
With oCmnDlg
.FileName = "DS.rtf"
' Prompt the user if the file already exists.
.Flags = cdlOFNHideReadOnly
' Determine if the cancel button was pressed.
.CancelError = True
.Filter = _
"Rich Text Format (*.rtf)|*.rtf"
.FilterIndex = 2
' Default the initial directory to "C:\My Documents".
.InitDir = "C:\My Documents" 'Windows\Temp"
'.ShowSave
' Determine what file type was selected; then save the
' file in that format.
strFormat = acFormatRTF
strFileName = .FileName
DoCmd.OutPutTo acOutputReport, "rptEmail_To_Recipients_DR
strFormat, strFileName
End With
Exit Function
Export_Exit:
Exit Function
Export_Err:
' Check to see if the cancel button was pressed.
If Err.Number = 32755 Then
Resume Export_Exit
Else: MsgBox "Action has been canceled.", vbOKOnly, DSVer
End If
Resume Export_Exit
End Function
**************************
Thanks,
ADawn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
EDDYKT
Did you comment-out .ShowSave or did you have the dialog show, then save to C:\"My Documents"?
Did you comment-out .ShowSave or did you have the dialog show, then save to C:\"My Documents"?
To my test program
I did not comment out .showsave but I use
.InitDir = "C:\program files" instead because I don't have
"C:\My Documents" in my computer.
That why I said are you sure "C:\My Documents" exists?
If not, it will not point you to initdir.
I did not comment out .showsave but I use
.InitDir = "C:\program files" instead because I don't have
"C:\My Documents" in my computer.
That why I said are you sure "C:\My Documents" exists?
If not, it will not point you to initdir.
Your destination is to to save the file (DS.rtf) to a specific directorythe following statements do this:
DoCmd.OutPutTo acOutputReport, "rptEmail_To_Recipients_DR ", _
strFormat, "C:\My Documents\DS.rtf"
This solution presumes that the dir C:\My Documents exists...
WoK?
DoCmd.OutPutTo acOutputReport, "rptEmail_To_Recipients_DR
strFormat, "C:\My Documents\DS.rtf"
This solution presumes that the dir C:\My Documents exists...
WoK?
ASKER
You're right, no need of common save dialog. For the save to file location (yes, "My Documents" exists), but this is want I used. strFileDir = "C:\My Documents" & "\" & FileName. I guess I could have used: "C:\My Documents\" & FileName.
Thanks for all the response. ADawn
Thanks for all the response. ADawn
ASKER
You're right, no need of common save dialog. For the save to file location (yes, "My Documents" exists), but this is want I used. strFileDir = "C:\My Documents" & "\" & FileName. I guess I could have used: "C:\My Documents\" & FileName.
Thanks for all the response. ADawn
Thanks for all the response. ADawn
' Default the initial directory to "C:\My Documents".
.InitDir = "C:\My Documents" 'Windows\Temp"
ARe your sure the dir c:\my documents exist?