Forcing SaveAs to overwrite

  • Thread starter Thread starter Swampy
  • Start date Start date
S

Swampy

Hi gang,

this seems like such a simple one, but buggered if I can get it t
work.

I have written some code;
Dim fname As Variant
Dim fname_date As Date
Dim msgbox_prompt As Variant

fname_date = Date
fname = "Export"

Application.ScreenUpdating = False
Windows("Awaiting review.xls").Activate
Sheets("Data").Select
Selection.AutoFilter Field:=2, Criteria1:="#N/A"
Selection.AutoFilter Field:=4, Criteria1:="0"
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Columns("B:D").Select
Selection.Delete Shift:=xlToLeft
ActiveWorkbook.SaveAs fname
ConflictResolution:=xlLocalSessionChanges
Windows("Awaiting review.xls").Activate
ActiveSheet.ShowAllData
Sheets("Summary").Select
Application.ScreenUpdating = True
msgbox_prompt = "SR's waiting review (excluding created date <
days) exported to " & fname
MsgBox (msgbox_prompt)
Windows(fname).Activate

I have three issues,:
a
- It prompts that the file exists, do you want to overwrite it;
just want it to overwrite without asking
- The windows(fname).activate fails, but I think that is because th
save is working successfully
- how do I format the date so that I can save the fname wher
fname_date will be export_10Sept
 
application.displayalerts = false
your saveas line of code
application.displayalerts = true
 

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