Solved

Common Dialog Issue(s) .ShowSave

Posted on 2002-03-07
7
339 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now