Среда ругается на каждый For Each p In ActiveDocument
Sub BatchProcessing()
Dim w As Word.Words
Dim sec As Word.Section
Dim r As Word.Range
Dim p As Word.Paragraph
Dim sen As Word.Sentences
Dim countP, n As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Title = "Âûáåðåòå ôàéëû äëÿ îáðàáîòêè"
.Filters.Clear
.Filters.Add "Word", "*.docm; *.docx; *.doc"
.InitialView = msoFileDialogViewDetails
.Show
For i = 1 To .SelectedItems.Count
For Each p In ActiveDocument.Sections(1).Range.Paragraphs
p.Range.Words(1).Bold = True
Next p
For Each p In ActiveDocument.Sections(2).Range.Paragraphs
If p.Range.Sentences.Count > 1 Then
p.Range.Sentences(1).Bold = True
p.Range.Sentences(2).Bold = True
Else
p.Range.Sentences(1).Bold = True
End If
Next p
Set doc = Documents.Open(.SelectedItems(i), Visible:=False)
doc.Save
doc.Close (True)
Next i
End With
End Sub