VBA to SAVE file Changes not work

chasoe

Board Regular
Joined
Jan 29, 2006
Messages
73
Dear Sirs,

I've been desperately debugging the following codes the whole morning, but still cannot find out where the problem lies.
The codes seems can perform each line of the scripts to the end, but all the files in the folder are not saved as intended.

The code is to automatically open each of the *CAL*.xls files, perform some tasks and then save the changes.

Code:
Sub CAL_File()

'Open each CAL file and format
'
'Ctrl+ L
'

Dim MyFiles As String
Dim CurrentFolder As String
Dim FileName As String
Dim myPath As String
Dim UniqueName As Boolean

UniqueName = False

'Store Information About Excel File
 
 Application.AskToUpdateLinks = False
 Application.DisplayAlerts = False
  
 MyFiles = Dir(ActiveWorkbook.Path & "\*CAL*.xl*")
 
 Do While MyFiles <> ""
  
  Workbooks.Open ActiveWorkbook.Path & "\" & MyFiles
  
  Call CALView
  
  Workbooks(2).Activate
  ActiveWorkbook.Close SaveChanges = True
     
  On Error GoTo 0
  
   MyFiles = Dir
   Loop
    
Application.AskToUpdateLinks = True
Application.DisplayAlerts = True
 

Exit Sub

End Sub

Sub CALView()
'
'hotkey : Ctrl + Shft + v
'
Workbooks(2).Activate
ActiveWindow.WindowState = xlNormal
With ActiveWindow
        .Top = 294.4
        .Left = 1.6
    End With
    With ActiveWindow
        .Width = 1150.8
        .Height = 278.4
    End With
    With ActiveWindow
        .Top = -0.2
        .Left = -0.8
    End With
    
 ActiveWindow.WindowState = xlMaximized
 
 Sheets(Array("CAL-Subcon", "CAL-Supplier", "CAL-IndirectExpense")).Select
 ActiveWindow.Zoom = 80
 
 Sheets(Array("CAL-GTT", "CAL-CostCodeList", "Summary")).Select
 ActiveWindow.Zoom = 100
 
 Sheets("CAL-GTT").Select
 Range("A2").Select

 
End Sub

Grateful if any could help.

Thanks in advance.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
This line is missing a colon
ActiveWorkbook.Close SaveChanges = True

Code:
ActiveWorkbook.Close SaveChanges[COLOR=#ff0000]:[/COLOR]=True

can also write like this
Code:
ActiveWorkbook.Close (True)
 
Upvote 0
OMG ! I've been struggling for the whole day just for the missing colon !
But there should be error message for this syntax error ! There seems to have no error message eventhough I've set DisplayAlerts = True.

Thx indeed.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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