Solved

File SaveAs, replacing existing one if it exists

Posted on 2014-01-02
2
246 Views
Last Modified: 2014-01-03
This code kicks back asking if I want to overwrite the existing file with the same name.  How do I tell it yes.  and do it every time?  Please advise and thanks. -R-

myDirECTorY = "C:\_SAP\ShortageRpt\DefaultExtractFiles\"        'Wherever you want
'myFileNameO = myDirECTorY & Format(Now(), "yyyymmdd_hhmm") & " ZSHORTV2DataCurrent" & ".xlsx"    'File name as desired.
myFileNameO = myDirECTorY & " ZSHORTV2DataCurrent" & ".txt"    'File name as desired.

Workbooks.Add
ActiveSheet.Paste

'Add text to column here

ActiveWorkbook.SaveAs Filename:=myFileNameO, FileFormat:= _
      xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close
 
MsgBox (" Done file saved ")

Open in new window

0
Comment
Question by:RWayneH
2 Comments
 
LVL 20

Accepted Solution

by:
dsacker earned 500 total points
ID: 39752947
Before your SaveAs, add this line of code:
Application.DisplayAlerts = False
After your SaveAs, add this line of code:
Application.DisplayAlerts = True
0
 

Author Closing Comment

by:RWayneH
ID: 39753751
Thanks, worked nicely. -R-
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

707 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

14 Experts available now in Live!

Get 1:1 Help Now