A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
If the workbooks contain automatic macros (for example Workbook_Open in the ThisWorkbook module), you can suppress them:
Sub ProcessWorkbooks()
Const strPassword = "test"
Const strPath = "C:\Users\hughesel\Desktop\Test"
Dim strFile As String
Dim wbk As Workbook
Dim wsh As Worksheet
' Temporarily hide screen activity
' You may still see some flickering
Application.ScreenUpdating = False
Application.EnableEvents = False
' Get first filename
strFile = Dir(strPath & "*.xls*")
' Loop
Do While strFile <> ""
' Open workbook
Set wbk = Workbooks.Open(Filename:=strPath & strFile)
' Reference to QPI sheet
Set wsh = wbk.Worksheets("QPI")
' Remove protection
wsh.Unprotect Password:=strPassword
' Replace formulas with values
With wsh.UsedRange
.Value = .Value
End With
' Apply protection again
wsh.Protect Password:=strPassword
' Close and save workbook
wbk.Close SaveChanges:=True
' On to the next file
strFile = Dir
Loop
Application.EnableEvents = True
' Display changes again
Application.ScreenUpdating = True
End Sub