Microsoft's drop down box

  • Thread starter Thread starter Sulley
  • Start date Start date
S

Sulley

Greetings,

I have a small request, I'm trying to save a file to my C drive and then get
it to save to my G drive. My question is ....
how do I get it to save to the G drive without Microsoft's drop down box
confirming (Yes) to replace the file?

Here is my code:

Sub Save()
ActiveWorkbook.Save
ChDir "G:\Excel Files"
ActiveWorkbook.SaveAs Filename:="G:\Excel Files\Audit Highlights.xls"
ChDir "c:\Temp 1"
End Sub

Any help would be greatly appreciated.
 
Sub Save()
Dim wbName As String
wbName = "G:\Excel Files\Audit Highlights.xls\Audit Highlights.xls"
ActiveWorkbook.Save
ActiveWorkbook.SaveAs wbName
End Sub

If you are overwriting an existing file you can suppress the alerts using:

Sub Save()
Dim wbName As String
wbName = "G:\Excel Files\Audit Highlights.xls\Audit Highlights.xls"
ActiveWorkbook.Save
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs wbName
Application.DisplayAlerts =True
End Sub

This is for a local drive G: only.
 
Hi Sulley -

I'd suggest turning off display alerts before and after the "...SaveAs..."
statement as follows:

Sub Save()
Application.DisplayAlerts = False
ActiveWorkbook.Save
ChDir "G:\Excel Files"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="G:\Excel Files\Audit Highlights.xls"
Application.DisplayAlerts = True
ChDir "c:\Temp 1"
End Sub
Close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top