When translating using DeepL in Excel macros, I want to translate English sentences as a whole in the cell, not as a period.

Asked 2 years ago, Updated 2 years ago, 528 views

As the title suggests, I would like to get the entire English sentence from the cell because the sentence is entered into DeepL with a period break, or just one sentence. I have changed the sentence. I changed the .Value part to .Text.

SubTranslate()

    Application.ScreenUpdating=False
    Application.Calculation=xlCalculationManual
    Dim Sh_1 As Worksheet
    Set Sh_1=Works("###########")
    Dimie As Object
    Setie=CreateObject("InternetExplorer.Application")
    ie.Visible=True
    Dim lastRow_1 As Long
    lastRow_1 = Sh_1.Cells(Rows.Count, 3).End(xlUp).Row
    Dim loop_1 As Long
    Dim S_English As String
    Dim S_wayaku As String

    For loop_1 = 3 LastRow_1
        S_english=Sh_1.Cells(loop_1,3).Value
        ie.navigate "https://www.deepl.com/ja/translator#en/ja/" & WorksheetFunction.EncodeURL(S_english)

        Do Whileie.BusyOrie.readyState<>4:DoEvents:Loop
        Do
            S_wayaku=ie.document.getElementsByClassName("lmt_target_textarea")(0).innerText
        Loop Until S_wayaku<>"
        Sh_1.Cells(loop_1,4).Value=S_wayaku
        Debug.Print loop_1
    Next

    ie. Quit'ie terminated
    Application.Calculation=xlCalculationAutomatic
    Application.ScreenUpdating=True

    MsgBox ("wd")

End Sub

vba natural-language-processing

2022-09-30 21:59

1 Answers

S_english=Sh_1.Cells(loop_1,3).Value

"There was a problem with processing ""/"" and ""()" and ""#"" in the expression in , and I was able to translate the whole sentence by correcting it."(i.e., the last part of the symbol to be processed, in this case, the value to be sent to DeepL)

If you change the symbol to an appropriate conjunction (as appropriate for "/" oror/and" etc.) in English, you will be able to translate the whole sentence in the cell without any problems.


2022-09-30 21:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.