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

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

قام بنشر

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

الأستاذة الافاضل في منتدى الاكسس

في قاعدة البيانات المرفقة وهي نموذج للمثال الذي اطمح واطمع من حضارتكم مساعدتي في عمل كود تشغيل ماكرو كنت قد سجلته في برنامج الاكسل ثم اخذت كود الماكرو ( الخاص بتنسيق ملف الاكسل ) ووضعته في وحدة نمطية ليتم استدعاء هذا الاجراء في button بعد تصدير ملف الاكسل ؟ 

لكي يظهر شيت الاكسل كما في الصورة المرفقةScreenshot2025-04-26183845.jpg.94a644c742c9dd2b824c75cfa70e7018.jpg

MergMic.rar

قام بنشر

تفضل استاذ @ابو عبد الله العراقي محاولتي حسب مافهمت . :fff:

Private Sub أمر3_Click()
    On Error GoTo met
    
    ' تصدير التقرير إلى ملف Excel
    Dim exportPath As String
    exportPath = CurrentProject.Path & "\Report_Export.xlsx"
    
    DoCmd.OutputTo acOutputReport, "Report1", acFormatXLSX, exportPath, False, , , acExportQualityPrint
    
    ' فتح ملف Excel وتنفيذ دمج الخلايا
    Dim xlApp As Object
    Dim xlBook As Object
    
    Set xlApp = CreateObject("Excel.Application")
    Set xlBook = xlApp.Workbooks.Open(exportPath)
    
    ' جعل Excel مرئيًا للمستخدم
    xlApp.Visible = True
    
    ' تنفيذ عملية دمج الخلايا
    With xlBook.Worksheets(1)
        .Range("A:B").WrapText = True
        .Range("A:B").HorizontalAlignment = -4108 ' xlCenter
        .Range("A:B").Merge
    End With
    
    ' حفظ الملف دون إغلاقه
    xlBook.Save
    
    ' تحرير الذاكرة (لن نغلق Excel هنا ليبقى مفتوحًا)
    Set xlBook = Nothing
    Set xlApp = Nothing
    
    MsgBox "تم تصدير الملف بنجاح ودمج الخلايا A/B، تم فتح ملف Excel للعرض"
    Exit Sub
    
met:
    MsgBox "حدث خطأ: " & Err.Description
    ' التأكد من إغلاق Excel في حالة الخطأ
    If Not xlApp Is Nothing Then
        xlApp.Quit
        Set xlBook = Nothing
        Set xlApp = Nothing
    End If
End Sub

 

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