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

كود ربط جدول اكسس بقوقل شيت الرجاء النظر في الكود


أبو امين

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

يمكنك استخدام VBA لربط جدول Access بجدول Google Sheets باستخدام Google API. يتطلب هذا الأمر إعدادات API وترخيص الوصول إلى جدول Google Sheets.

فيما يلي مثال بسيط لنسخ بيانات جدول Access إلى جدول Google Sheets باستخدام Google API:

 

 

 

Sub ExportToGoogleSheets()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim conn As New ADODB.Connection
    Dim rsGoogle As New ADODB.Recordset
    Dim strConn As String
    
    ' Connection string to Google Sheets
    strConn = "Provider=MSDataShape;Data Provider=Google Sheets; " & _
                "Data Source=spreadsheet_key; " & _
                "User ID=username;Password=password; " & _
                "Extended Properties=""HDR=Yes;"";"
    
    ' Open connection to Google Sheets
    conn.Open strConn
    
    ' Open recordset for Access table
    Set db = CurrentDb
    Set rs = db.OpenRecordset("SELECT * FROM myTable")
    
    ' Loop through records and copy to Google Sheets
    Do Until rs.EOF
        rsGoogle.Open "SELECT * FROM Sheet1", conn, adOpenKeyset, adLockOptimistic
        rsGoogle.AddNew
        rsGoogle.Fields("Field1").Value = rs.Fields("Field1").Value
        rsGoogle.Fields("Field2").Value = rs.Fields("Field2").Value
        rsGoogle.Update
        rsGoogle.Close
        rs.MoveNext
    Loop
    
    ' Clean up
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    conn.Close
    Set conn = Nothing
End Sub

تغيير "spreadsheet_key" إلى مفتاح جدول Google Sheets الخاص بك و "username" و "password" إلى اسم المستخدم وكلمة المرور الخاصة بحساب Google الخاص بك. يجب أن تضمن مكتبة ADODB في مشروع VBA الخاص بك.

تحتاج أيضًا إلى تنزيل برنامج تشغيل Microsoft OLE DB Provider for ODBC Drivers وتثبيته للحصول على الوصول إلى Google Sheets. يمكنك تنزيل البرنامج التشغيلي من خلال الرابط التالي: https://www.microsoft.com/en-us/download/details.aspx?id=13255

بعد تثبيت البرنامج التشغيلي، قم بإعداد اتصال ODBC باستخدام بيانات اعتماد Google الخاصة بك والمفتاح المميز لجدول Google Sheets الخاص بك. يمكنك إعداد الاتصال الخاص بك باستخدام Control Panel في Windows.

 

المطلوب : اين اضع هذا الكود هل اضعه في زر امر ام في وحدة نمطية 

 

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

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