اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

كيف نُصدر المرفقات الموجودة في حقل معين في أكسس إلى مجلد خارجي


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

وعليكم السلام

تفضل اخي الكريم

Public Sub ExportAttachments()
    Dim rs As DAO.Recordset
    Dim attachmentField As DAO.Field2
    Dim attachmentRS As DAO.Recordset2
    Dim attachmentCount As Long
    Dim attachmentPath As String

    attachmentPath = CurrentProject.Path & "\Saving\"
    Set rs = CurrentDb.OpenRecordset("Table1")
    If Not (rs.EOF And rs.BOF) Then
        rs.MoveFirst
        Do Until rs.EOF
            Set attachmentField = rs.Fields("Attachments")
            If Not attachmentField.Value Is Nothing Then
                Set attachmentRS = attachmentField.Value
                For attachmentCount = 1 To attachmentRS.RecordCount
                    If Not FileExists(attachmentPath & attachmentRS.Fields("FileName")) Then
                        attachmentRS.Fields("FileData").SaveToFile attachmentPath & attachmentRS.Fields("FileName")
                        MsgBox "تم تصدير الملفات التالية: " & attachmentPath & attachmentRS.Fields("FileName"), vbInformation, "تمت عملية التصدير بنجاح "

                    Else
                        MsgBox "الملف موجود مسبقا تم إلغاء عملية التصدير: " & attachmentPath & attachmentRS.Fields("FileName"), vbCritical, "تم إلغاء عملية التصدير "
                    End If
                    attachmentRS.MoveNext
                Next attachmentCount
            End If
            rs.MoveNext
        Loop
    End If
    rs.Close
    Set rs = Nothing
    Set attachmentRS = Nothing
End Sub

Function FileExists(filePath As String) As Boolean
    FileExists = Dir(filePath) <> ""
End Function

 'والاستدعاء
Private Sub Command3_Click()
    ExportAttachments
End Sub

وهذا ملف من  عندي

بالتوفيق

تصدير المرفقات الى ملف خارجي.rar

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

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