Saving Report as PDF - Save As Prompt

I'm using the following code to save a report as a PDF file.  Everything works but the Save As box pops up requesting a file name and another box after that asking whether or not I want to replace the existing file.  I want it to automatically save the file and replace the existing file.  How can I do this?

   Dim db As Database
   Dim rs As Recordset
   Dim rpt As Report
   Dim strReportName As String
   strReportName = "Report1"
   Set db = CurrentDb
   Set rs = db.OpenRecordset("DevStructure")
   DoCmd.OpenReport strReportName, acViewDesign
   Set rpt = Application.Reports(strReportName)
   rpt.PrtDevMode = rs.Fields(0)
   rpt.PrtDevNames = rs.Fields(1)
   DoCmd.OpenReport strReportName, acViewNormal
   DoCmd.Close acReport, strReportName, acSaveNo
Who is Participating?
TextReportConnect With a Mentor Commented:
you can delete the old file before doing the save Kill "filename". As far as the prompt for the filename all i can think of is to try sendkeys "c:\...~" the ~ will do an enter and you may want to try this first without the ~ to test that the keys are been sent to the correct window.

Cheers, Andrew
drees727Author Commented:
Using the sendkeys worked.  Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.