Disable save changes box

ryan8200

Active Member
Joined
Aug 21, 2011
Messages
357
I tried to add csv files from download folder to current workbook. The process is interrupted and asking whether I want to save changes to csv file.
How to disable the save changes box ?
VBA Code:
Sub  AddCSV()
Path = "C:\Users\My\Downloads\"
Filename = Dir(Path & "*.csv")

' Disable Screen Updating is used to stop screen flickering and Disable Events is used to avoid interrupted dialog boxes / popups
With Application
    .ScreenUpdating = False
    .EnableEvents = False
End With

  Do While Filename <> ""
  
  Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
     For Each sheet In ActiveWorkbook.Sheets
     sheet.Copy After:=ThisWorkbook.Sheets(1)
  Next sheet
     Workbooks(Filename).Close
     Filename = Dir()
  Loop
  
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
As csv files only have 1 sheet there is no need for the For Next loop.
Try
VBA Code:
Do While Filename <> ""
  
  with Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
     .Sheets(1).Copy After:=ThisWorkbook.Sheets(1)
     .Close False
   End With
     Filename = Dir()
  Loop
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,699
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top