Thread: [Solved] Need Help with this Macro
View Single Post
 
Old 09-24-2018, 10:40 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

On the face of it the problem relates to the way you have pasted the text. If I understand the problem correctly, the following macro will paste the text from Google translate with the text formatted with the format at the cursor position
Code:
Sub PasteUnfText()
    On Error GoTo err_Handler
    Selection.PasteSpecial DataType:=wdPasteText, _
                           Placement:=wdInLine
lbl_Exit:
    Exit Sub
err_Handler:
    Beep
    Err.Clear
    GoTo lbl_Exit
End Sub
If you want to apply particular formatting then you can do that at the same time e.g.
Code:
Sub PasteSpanishText()
Dim oRng As Range, oStart As Range
    On Error GoTo err_Handler
    Set oRng = Selection.Range
    Set oStart = oRng.Duplicate
    With oRng
        .PasteSpecial DataType:=wdPasteText, _
                      Placement:=wdInLine
        .Start = oStart.Start
        .LanguageID = wdSpanishModernSort
        .NoProofing = False
        Application.CheckLanguage = False
        .Collapse 0
        .Select
    End With
lbl_Exit:
    Set oRng = Nothing
    Set oStart = Nothing
    Exit Sub
err_Handler:
    Beep
    Err.Clear
    GoTo lbl_Exit
End Sub
Better still create a Spanish style (or styles) that has the characteristics required and apply it. You could do that as you paste also bu formatting the range with the style.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote