وعليكم السلام ورحمة الله تعالى وبركاته
جرب هدا
Private Const sFolder As String = "ملفات PDF"
Private Const CrWS As String = "لجان 4"
Sub SavePDF()
Dim f As Worksheet, début As Integer, fin As Integer, i As Integer
Dim sPath As String, sName As String, tempFile As String
Set f = Sheets(CrWS)
If Not IsNumeric(f.[B1].Value) Or Not IsNumeric(f.[S2].Value) Then Exit Sub
début = f.[B1].Value: fin = f.[S2].Value
If début < 1 Or fin < 1 Or début > fin Then Exit Sub
If MsgBox("هل ترغب بحفظ الصفحات من " & début & " إلى " & fin & "؟", vbYesNo + vbExclamation, "تأكيـــد") = vbNo Then Exit Sub
Application.ScreenUpdating = False
tempFile = ThisWorkbook.Path & "\" & sFolder
If Dir(tempFile, vbDirectory) = "" Then MkDir tempFile
For i = début To fin Step 2
f.[B1].Value = i
sName = f.[F7].Value & IIf(f.[M7].Value <> "", " - " & f.[M7].Value, "")
sPath = tempFile & "\" & "Page - " & sName & ".pdf"
On Error Resume Next
f.ExportAsFixedFormat Type:=xlTypePDF, fileName:=sPath, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
On Error GoTo 0
Next i
Application.ScreenUpdating = True
MsgBox "تم حفظ الملفات بنجاح", vbInformation
End Sub
المصنف v2.xlsb