How to save file without the save message?

  • Thread starter Thread starter Together
  • Start date Start date
T

Together

Hi,
How to save file after change without the save message? I read man
thead. But it do not work.

Application.DisplayAlerts = False
ThisWorkbook.Save
ActiveWorkbook.Close

This code does not save change!
 
Which are you trying to work with

Thisworkbook (the workbook with the code)

or

ActiveWorkbook



Thisworkbook.Close SaveChanges:=True

or

ActiveWorkbook.Close SaveChanges:=True
 
Thank you, Sir
But it seems that it still can not work.

The code:

Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=True

is the same as:

ActiveWorkbook.Close SaveChanges:=True


I use the VBA to analyze some data in workbook. After I finish it,
hope the workbook can close automaticly with saving the change I made
 
here is the code:
Sub module3()

Dim m As Integer
Dim value As Integer
Dim i, j, n As Integer
Dim k As String
Dim DaSourceFile As String, DaSourceAfter As String

DaSourceAfter = "D:\Excel\" 'fix the folder direction

DaSourceFile = Dir(DaSourceAfter & "*.xls") 'get the file *.xls

'loop through all of the txt files

Do While DaSourceFile <> ""
Workbooks.Open Filename:=DaSourceAfter & DaSourceFile 'open one file

Worksheets.Add
Worksheets(1).Activate
j = 2 'the fisrt row is used for note
Worksheets(1).Cells(1, 1) = "lane1"
Worksheets(1).Cells(1, 2) = "lane2"
Worksheets(1).Cells(1, 3) = "lane3"
Worksheets(1).Cells(1, 4) = "total volume"
n = 1 'fix the first column as the volume of different lane
For i = 1 To 700 'row search the volume
Worksheets(2).Activate ' this sheet contains the data from cosim
If Worksheets(2).Cells(i, 9) = "RADAR" Then 'Search condition for row
value = Worksheets(2).Cells(i, 10).value ' the data needed in th
project
Worksheets(1).Activate ' this sheet contains the data I need
Worksheets(1).Cells(j, n) = value 'give the value of sheet1 to sheet2
n = n + 1
If n = 4 Then 'sum the volume in different lanes
Worksheets(1).Cells(j, 4) = Worksheets(1).Cells(j, 1) + _
Worksheets(1).Cells(j, 2) + Worksheets(1).Cells(j, 3)
j = j + 1
n = 1
End If
Worksheets(2).Activate
End If

Next i

'Application.DisplayAlerts = False

ActiveWorkbook.Save

ActiveWorkbook.Close SaveChanges:=True

DaSourceFile = Dir()

Loop
End Su
 
I got it. Thank all of you.
The problem is that the format of my excel file is not xlwindownormal
 
That isn't a valid format anyway. the format is

xlWorkbookNormal

or

xlNormal

? xlWorkbookNormal
-4143
? xlNormal
-4143
? xlWindowNormal

the last produced nothing.
 
Back
Top