Solved

Common Dialog Issue(s) .ShowSave

Posted on 2002-03-07
7
341 Views
Last Modified: 2008-02-26
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_SaveAsMViewDRRTF()
On Error GoTo Export_Err

Dim oCmnDlg As CommonDialog
Dim strFormat As String
Dim strFileName As String

Set oCmnDlg = Forms!frm_EmailDailyToRecipients!CommonDialog_Email.Object

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
0
Comment
Question by:ADawn
  • 3
  • 2
  • 2
7 Comments
 
LVL 4

Accepted Solution

by:
WolfgangKoenig earned 35 total points
ID: 6847111
Have you try this?
--------------------
DoCmd.OutPutTo acOutputReport, "rptEmail_To_Recipients_DR", _
  strFormat, strFileDir & strFileName

I think you don't need the Common Save Dialog to
save the rtf file you must only set the fully path
and filename in the OutPutTo command like the above
example ...

Regards;)
WoK


 

0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 6847120
It work for me.

' Default the initial directory to "C:\My Documents".
  .InitDir = "C:\My Documents" 'Windows\Temp"


ARe your sure the dir c:\my documents exist?
0
 

Author Comment

by:ADawn
ID: 6847335
EDDYKT

Did you comment-out .ShowSave or did you have the dialog show, then save to C:\"My Documents"?
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 26

Expert Comment

by:EDDYKT
ID: 6847377
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.
0
 
LVL 4

Expert Comment

by:WolfgangKoenig
ID: 6847469
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?



0
 

Author Comment

by:ADawn
ID: 6847656
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
0
 

Author Comment

by:ADawn
ID: 6847658
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
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question