Translate text using vba

后端 未结 5 1170
既然无缘
既然无缘 2020-11-29 07:08

Probably could be a rare petition, but here is the issue.

I am adapting an excel of a third-party to my organization. The excel is developed in English and the peop

5条回答
  •  悲&欢浪女
    2020-11-29 07:36

    The answer posted by Unicco is great!

    I removed the table stuff and made it work off a single cell, but the result is the same.

    With some of the text I translate (operation instructions in a manufacturing context) Google occasionally adds crap to the return string, sometimes even doubling the response, using additional <"span"> constructs.

    I added the following line to the code right after 'Next v':

    s_Translation = RemoveSpan(s_Translation & "")
    

    And created this function (add to the same module):

    Private Function RemoveSpan(Optional InputString As String = "") As String
    
    Dim sVal As String
    Dim iStart As Integer
    Dim iEnd As Integer
    Dim iC As Integer
    Dim iL As Integer
    
    If InputString = "" Then
        RemoveSpan = ""
        Exit Function
    End If
    
    sVal = InputString
    
    ' Look for a " 0 ' there is a "" following the " 1 Then ' the ""
            Else ' the ""
            End If
        End If
        iStart = InStr(1, sVal, "

    In retrospect, I realize I could have done this more efficiently, but, it works and I am moving on!

提交回复
热议问题