none
How do I COPY (not paste) text wothout formating? RRS feed

  • Question

  • How do I COPY (not paste) text wothout formating?  I tried "Copy Text" and "Copy Ink As Text" but they both bring over formating (fonts, etc...).  In fact, I didn't see any difference between "Copy", "Copy Text" and "Copy Ink As Text".

    I just need plain text to copy from Word 2010 in to another appication.  Right now I copy Word text in to Notepad and from Notepad to another application.

    Thursday, October 22, 2015 4:31 PM

Answers

  • Hi Izabella

    Since you ask this in the Word for Developers forum - a programming forum - I'm going to assume you want a coded answer, a macro. This can be done quite easily with a macro. The following puts the "plain text" on the Clipboard so that you can paste it anywhere. You can assign the macro to your Ribbon QAT, a Ribbon button (if this is 2010 or more recent) and/or to a keyboard shortcut

    Sub PutPlainTextOnClipboard()
        Dim rng As word.Range
        Dim sText As String
        Dim dObj As MSForms.DataObject
        
        Set rng = Selection.Range
        Set dObj = New DataObject
        sText = rng.Text
        dObj.SetText sText
        dObj.PutInClipboard
    End Sub
    


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Thursday, October 22, 2015 6:29 PM
    Moderator
  • A small addition: for Cindy's code to work, you need to set a reference in Tools > References... to the Microsoft Forms 2.0 Object Library.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Thursday, October 22, 2015 6:46 PM
  • Hi,

    To use MSForms.DataObject, we need to add the reference as Hans suggested. If we can't find the reference in the reference dialog, we need to add the reference via browser the FM20.dll under Windows\System32 folder.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 23, 2015 2:02 AM
    Moderator

All replies

  • As far as I know, Word does not have a "copy without formatting" option.

    Using Notepad as intermediate step, as you do now, is probably the best workaround.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Thursday, October 22, 2015 5:09 PM
  • Hi Izabella

    Since you ask this in the Word for Developers forum - a programming forum - I'm going to assume you want a coded answer, a macro. This can be done quite easily with a macro. The following puts the "plain text" on the Clipboard so that you can paste it anywhere. You can assign the macro to your Ribbon QAT, a Ribbon button (if this is 2010 or more recent) and/or to a keyboard shortcut

    Sub PutPlainTextOnClipboard()
        Dim rng As word.Range
        Dim sText As String
        Dim dObj As MSForms.DataObject
        
        Set rng = Selection.Range
        Set dObj = New DataObject
        sText = rng.Text
        dObj.SetText sText
        dObj.PutInClipboard
    End Sub
    


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Thursday, October 22, 2015 6:29 PM
    Moderator
  • A small addition: for Cindy's code to work, you need to set a reference in Tools > References... to the Microsoft Forms 2.0 Object Library.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Thursday, October 22, 2015 6:46 PM
  • Thank you.  This is nearly perfect.

    There is a problem with following line:
       Dim dObj As MSForms.DataObject

    I get following error:
       "Compile error:
       User-Defined type not defined"

    Thursday, October 22, 2015 10:12 PM
  • Hi,

    To use MSForms.DataObject, we need to add the reference as Hans suggested. If we can't find the reference in the reference dialog, we need to add the reference via browser the FM20.dll under Windows\System32 folder.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 23, 2015 2:02 AM
    Moderator