Your code modified
Sub aggiorna()
'With Foglio12
Dim myWB As Workbook
Dim mySheet As Worksheet
Dim Myfile As String
Dim riga As Integer
Dim col As Integer
Dim num_righe As Integer
Dim xWS As Worksheet
Dim xComment As Comment
Set myWB = ThisWorkbook
Set mySheet = myWB.ActiveSheet '* check if this the correct sheet
num_righe = 500
col = 7 'percorsi in colonna E
riga = 5 'parte da riga 1
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.DisplayAlerts = False
.ScreenUpdating = False
End With
For riga = 5 To 350 'num_righe
Myfile = mySheet.Cells(riga, col).Value
If Myfile <> "" And Dir(Myfile) <> "" Then
Workbooks.Open Filename:=Myfile, UpdateLinks:=False
' Workbooks(Dir(Myfile)).RefreshAll
For Each xWS In Application.ActiveWorkbook.Sheets
For Each xComment In xWS.Comments
xComment.Delete
Next
Next
'Disable privacy settings warning
Workbooks(Dir(Myfile)).Close SaveChanges:=True
End If
Next riga
With Application
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub
Bookmarks