اذهب الي المحتوي
أوفيسنا

الردود الموصى بها

  • تمت الإجابة
قام بنشر (معدل)

وعليكم السلام ورحمة الله تعالى وبركاته 

جرب هدا

حفظ الملفات في تفس مسار الملف 

Option Explicit
Sub SAVE_PDF()
    Dim ScWS As Variant, Path As String, i As Integer
    ScWS = Array("Sheet1", "Sheet2", "Sheet3")
    Path = ThisWorkbook.Path & "\"

    If Path = "\" Then Exit Sub
    For i = LBound(ScWS) To UBound(ScWS)
        If Not ShExists(ScWS(i)) Then MsgBox "الورقة " & ScWS(i) & " غير موجودة": Exit Sub
        Application.ScreenUpdating = False
        On Error Resume Next
        Sheets(ScWS(i)).ExportAsFixedFormat Type:=xlTypePDF, FileName:=Path & ScWS(i) & ".pdf", _
            Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        On Error GoTo 0
    Next i
    Application.ScreenUpdating = True
    MsgBox "تم حفظ الملفات بنجاح"
End Sub

لإنشاء مجلد وحفظ الملفات بداخله

Sub SAVE_PDF_Folder()
    Dim ScWS As Variant, Path As String, Dossier As String, i As Integer
    ScWS = Array("Sheet1", "Sheet2", "Sheet3")
    Path = ThisWorkbook.Path & "\"
    Dossier = "ملفات PDF"

    If Path = "\" Then Exit Sub
    If Dir(Path & Dossier, vbDirectory) = "" Then MkDir Path & Dossier
    
    Path = Path & Dossier & "\"
    For i = LBound(ScWS) To UBound(ScWS)
        If Not ShExists(ScWS(i)) Then MsgBox "الورقة " & ScWS(i) & " غير موجودة": Exit Sub
        Application.ScreenUpdating = False
        On Error Resume Next
        Sheets(ScWS(i)).ExportAsFixedFormat Type:=xlTypePDF, FileName:=Path & ScWS(i) & ".pdf", _
            Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        On Error GoTo 0
    Next i
    Application.ScreenUpdating = True
    MsgBox "تم حفظ الملفات بنجاح"
End Sub
Function ShExists(ByVal SheetName As String) As Boolean
    On Error Resume Next: ShExists = Not Sheets(SheetName) Is Nothing: On Error GoTo 0
End Function

 

 

حفظ الملفات مستقلة بصيغة PDF.xlsb

تم تعديل بواسطه محمد هشام.
  • Like 2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information