ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   P (https://www.excelbanter.com/excel-discussion-misc-queries/216958-p.html)

TFMR

P
 
Dear All,

I am using following to apply macro on all files in a folder. on close of
everyfile the msg box appear, you want to save and three option Yes No
Cancel. How its possible that all the files saves and go on next file without
appearing any msg box?

Your help required with thnx



Sub list_um()
Dim F As String
Dim roww As Long
roww = 0
Dim FileLocSpec As String
FileLocSpec = "C:\Hassan\*.csv"
F = Dir(FileLocSpec)
Do Until F = ""
roww = roww + 1
Cells(roww, 1).Value = F
F = Dir
Loop

Set r = Range("A1")
While r.Value < ""
Workbooks.Open Filename:="C:\Hassan\" & r.Value
Call Wathba
ActiveWorkbook.Save
ActiveWorkbook.Close

Set r = r.Offset(1, 0)
Wend
End Sub


Sheeloo[_3_]

P
 
Instead of
ActiveWorkbook.Save
ActiveWorkbook.Close

use

ActiveWorkbook.Close SaveChanges:=True

"TFMR" wrote:

Dear All,

I am using following to apply macro on all files in a folder. on close of
everyfile the msg box appear, you want to save and three option Yes No
Cancel. How its possible that all the files saves and go on next file without
appearing any msg box?

Your help required with thnx



Sub list_um()
Dim F As String
Dim roww As Long
roww = 0
Dim FileLocSpec As String
FileLocSpec = "C:\Hassan\*.csv"
F = Dir(FileLocSpec)
Do Until F = ""
roww = roww + 1
Cells(roww, 1).Value = F
F = Dir
Loop

Set r = Range("A1")
While r.Value < ""
Workbooks.Open Filename:="C:\Hassan\" & r.Value
Call Wathba
ActiveWorkbook.Save
ActiveWorkbook.Close

Set r = r.Offset(1, 0)
Wend
End Sub



All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com