Option Explicit
Const PATH_SOURCE_COLUMN As String = "A"
Const SAVE_NAME_COLUMN As String = "C"
Public Sub ExportSheets_AsPDF()
On Error Resume Next
Dim oBook As Workbook, WS As Worksheet
Dim strPath As String
Dim iRow As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
For iRow = 1 To Cells(Rows.Count, 1).End(xlUp).Row
strPath = Cells(iRow, PATH_SOURCE_COLUMN)
If InStr(strPath, ":\") <> 0 Then 'IsPath
Set oBook = Workbooks.Open(strPath, True, False)
If Not (oBook Is Nothing) Then
ReplaceSurname oBook
oBook.Close True
End If
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
End Sub
Private Sub ReplaceSurname(oBook As Workbook)
Dim WS As Worksheet
Set WS = oBook.Sheets("дано")
'снять защиту
WS.Unprotect "qqq"
WS.Unprotect
WS.Range("B21").FormulaR1C1 = "Батуева М.О."
WS.Range("B20").FormulaR1C1 = "Велорапко О.М."
'вернуть защиту
oBook.Sheets("дані договору").Protect "qqq"
'просмотр
oBook.Sheets("04").Activate
End Sub