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

تعديل كود تصدير PDF


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

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

 

اسعد الله جميع اوقاتكم بكل خير 

 

لدي كود تصدير ورقة العمل من اكسل الي PDF

 

وتعمل بشكل صحيح. 

 

لدي sheet1 يتم ادخال كافة البيانات فيه 

 

و sheet2 مخفي غير ظاهر ويأخذ بيانات محددة من sheet1 

 

المطلوب تعديل في الكود بحيث

 

يتم تصدير sheet2 الي PDF

 

"

Sub PDFActiveSheet() Dim wsA As Worksheet Dim wbA As Workbook Dim strTime As String Dim strName As String Dim strPath As String Dim strFile As String Dim strPathFile As String Dim myFile As Variant On Error GoTo errHandler Set wbA = ActiveWorkbook Set wsA = ActiveSheet strTime = Format(Now(), "yyyymmdd\_hhmm") strPath = wbA.Path If strPath = "" Then strPath = Application.DefaultFilePath End If strPath = strPath & "\" strName = Replace(wsA.Name, " ", "") strName = Replace(strName, ".", "_") strFile = strName & "_" & strTime & ".pdf" strPathFile = strPath & strFile myFile = Application.GetSaveAsFilename _ (InitialFileName:=strPathFile, _ FileFilter:="PDF Files (*.pdf), *.pdf", _ Title:="Select Folder and FileName to save") If myFile <> "False" Then wsA.ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=myFile, _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _ OpenAfterPublish:=False MsgBox "PDF file has been created: " _ & vbCrLf _ & myFile End If exitHandler: Exit Sub errHandler: MsgBox "Could not create PDF file" Resume exitHandler End Sub

 

 

رابط هذا التعليق
شارك

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

جرب هذا


Sub PDF()
Dim ws As Worksheet
Dim strPath As String
Dim myFile As Variant
Dim strFile As String
On Error GoTo errHandler 
Set ws = Sheets("sheet2") 
strFile = Replace(Replace(ws.Name, " ", ""), ".", "_") _
            & "_" _
            & Format(Now(), "yyyymmdd\_hhmm") _
            & ".pdf"
strFile = ThisWorkbook.Path & "\" & strFile 
myFile = Application.GetSaveAsFilename _
    (InitialFileName:=strFile, _
        FileFilter:="PDF Files (*.pdf), *.pdf", _
        Title:="Select Folder and FileName to save") 
If myFile <> "False" Then
    ws.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:=myFile, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False 
    MsgBox "PDF file has been created."
End If 
exitHandler:
    Exit Sub
errHandler:
    MsgBox "Could not create PDF file"
    Resume exitHandler
End Sub

 

رابط هذا التعليق
شارك

13 ساعات مضت, احمد بدره said:

بارك الله فيك هذا المطلوب

هل بالامكان عدم ظهور sheet2 نهائيا؟ 

رابط هذا التعليق
شارك

للأسف لا يمكن حفظ ورقة عمل بنوع PDF وهي مخفية فلابد من التحايل بعمل كود إظهار ورقة العمل قبل الحفظ وكود آخر يقوم بإخفاء ورقة العمل مرة أخرى بعد الحفظ 

مع خالص تحياتي

  • Thanks 1
رابط هذا التعليق
شارك

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