Solved

Common Dialog Issue(s) .ShowSave

Posted on 2002-03-07
7
340 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

831 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