Solved

Common Dialog Issue(s) .ShowSave

Posted on 2002-03-07
7
338 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 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

22 Experts available now in Live!

Get 1:1 Help Now