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

تعديل كود الترجمة باستخدام google translate


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

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

حياكم الله جميعا

وجدت هذا الكود على النت يقوم بترجمة النصوص داخل النموذج عن طريق كوكل ترانسليت

Option Compare Database

Declare PtrSafe Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)

Global LangFrom As String
Global LangTo As String


Public Function AutoTranslate(ByVal Text As String)
    'Add references to [Microsoft Internet Controls], [Microsoft Scripting Runtime] and [Microsoft 14.0 Object Library]
'    On Error GoTo Err_Point






    Dim IE As InternetExplorer
    Dim URL As String
    Dim liCount As Integer
  
    
    Text = Replace(Text, "/", "")
    Text = Replace(Text, "\", "")
    For liCount = 0 To 31
      Text = Replace(Text, Chr(liCount), "")
    Next liCount
  If Len(LangFrom) < 1 Then
  LangFrom = "ar"
  End If
   If Len(LangTo) < 1 Then
  LangTo = "en"
  End If
   
   
'"https://translate.google.com/#" & langfrom  & "/" & langto & "/" &   text
    URL = "https://translate.google.com.tr/" & LangFrom & "/" & LangTo & "/" & Text
    
    Set IE = New InternetExplorer
    IE.Visible = False
    IE.Navigate URL
    Do Until IE.ReadyState = 4
        DoEvents
    Loop
    
    Sleep 1000
    AutoTranslate = IE.Document.querySelector(".tlid-translation.translation").innerText
    IE.Quit
    Set IE = Nothing
    
    Exit Function

Err_Point:
    IE.Quit
    Set IE = Nothing

    strMsg = err.Number & Chr(13) & err.Description
    strTitle = "Error during translation"
    strResponse = MsgBox(strMsg, vbCritical, strTitle)
End Function

دائما يظهر لي خطأ عند الكود التالي:

AutoTranslate = IE.Document.querySelector(".tlid-translation.translation").innerText

فما السبب

 

Google-Tran.accdb

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

هذا الكود خاص بالأكسل و الخطأ رقم 424 عندما تبحث عن سببه تجد مرجعيته للأكسل.

لكن الأمر المحير في الملف هو أنه بالصدفة عند الضغط على زر الترجمة مرتين يظهر الخطأ و لكن في نفس الوقت يقوم بالترجمة و يفتح صفحة الويب ربما بداية الحل من هنا

الضغط مرتين أقصد به double click جرب و لاحظ النتيجة

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

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