Hi Paolone,
I am an independent advisor, trying to help other users in the Community with my experience in Microsoft products. Please note that I am a user like you and don't work directly for Microsoft.
Unfortunately, recording a macro doesn’t capture the translation action directly. However, you can try to achieve this using VBA code.
Open your Word document that contains the text you want to translate.
Press Alt + F11 to open the Visual Basic for Applications (VBA) editor.
Insert a new module by clicking on “Insert” > “Module.”
Copy and paste the modified VBA code below into the module:
Public Sub TranslateToItalian()
Dim selectedText As String
Dim translatedText As String
' Get the currently selected text in the active document
selectedText = Selection.Text
' Translate the selected text to Italian
translatedText = TranslateText(selectedText, "auto", "it")
' Replace the selected text with the translated version
Selection.Text = translatedText
End Sub
Function TranslateText(ByVal textToTranslate As String, ByVal fromLang As String, ByVal toLang As String) As String
' You can customize this function to handle translation
' using your preferred method or service
' For now, let's return a placeholder translated text
TranslateText = "Placeholder translation to Italian: " & textToTranslate
End Function
Customize the TranslateText function within the code to perform the actual translation. Replace the placeholder logic with your preferred translation method or service.
Close the VBA editor and return to your Word document.
Select the text you want to translate.
Run the macro by pressing Alt + F8, selecting “TranslateToItalian,” and clicking “Run.”
The selected text will be replaced with the translated Italian text. Remember to adapt the TranslateText function to your specific translation needs.
I would appreciate your feedback.
Kindly note that this is a user-to-user forum, we are users helping other users, we aren't Microsoft employees and neither are we Microsoft agents.
Best regards,
Amadeusz