Solved

Common Dialog Issue(s) .ShowSave

Posted on 2002-03-07
7
354 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month4 days, 5 hours left to enroll

630 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