Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

File SaveAs, replacing existing one if it exists

Posted on 2014-01-02
2
Medium Priority
?
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
dsacker earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

688 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