Consulting

Results 1 to 8 of 8

Thread: MS Word overwrite Paste Options:

  1. #1

    MS Word overwrite Paste Options:

    Hi,

    I want to restrict a document so that all paste actions result in plain text being added to the document.

    I am able to over-write the default behaviour of CTRL + V using this procedure:
    Sub EditPaste()
        Selection.PasteAndFormat (wdFormatPlainText)
    End Sub
    I am now trying to restrict the Paste Options. (under right-click)
    I haven't had any luck googling a good answer.
    Does anyone know how to restrict Paste Options to only show "Keep Text Only"

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,050
    Location
    Assuming you are using a Microsoft system, In Word, select Options...Advanced. Under Cut, copy, and paste, set all the "Pasting" settings to Keep Text Only
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    Quote Originally Posted by Aussiebear View Post
    Assuming you are using a Microsoft system, In Word, select Options...Advanced. Under Cut, copy, and paste, set all the "Pasting" settings to Keep Text Only
    I'm pretty sure that would change the behaviour of the MS Word application on my computer.
    To clarify: I'm looking to add VBA to a document, so that if someone else opens that document (on their computer), they are restricted to pasting text-only

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,050
    Location
    Then I suggest you record the method of completing that which was indicated to Post #2 and then upload the code here so that we can modify it to suit your needs.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    Note that there is no way you can be sure that another user will allow your code to run.

  6. #6
    Quote Originally Posted by Chas Kenyon View Post
    Note that there is no way you can be sure that another user will allow your code to run.
    This I kind of already solved.
    I run this procedure before I save the document:

    Sub hideAll()
        ThisDocument.Range.Font.Hidden = True
    End Sub
    The document then has a picture-button-macro that triggers the reverse action.
    ..They need to enable macros to see the form

  7. #7
    Quote Originally Posted by Aussiebear View Post
    Then I suggest you record the method of completing that which was indicated to Post #2 and then upload the code here so that we can modify it to suit your needs.
    I'm not quite ready to go down the path you have suggested.
    This means using VBA to change the default behaviour of MS Word on the client computer.
    That feels invasive. (might be a genius work around, where nothing else will work)

    Ideally I'm seeking a solution that only affects the document in question.


    This code:
    Sub EditPaste()
        Selection.PasteAndFormat (wdFormatPlainText)
        MsgBox "testing"
    End Sub
    Works because EditPaste is a builtin method/macro that is triggered by CTRL + V

    The problem is that EditPaste is not triggered when the user chooses Paste Options:
    And I have no idea what is triggered when they use Paste Options:

    If someone knows how to inject code when the user chooses Paste Options: ... that would be very helpful

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,050
    Location
    Quote Originally Posted by Norsak View Post
    This means using VBA to change the default behaviour of MS Word on the client computer.
    That feels invasive. (might be a genius work around, where nothing else will work)

    Ideally I'm seeking a solution that only affects the document in question.

    If someone knows how to inject code when the user chooses Paste Options: ... that would be very helpful
    As Chas Kenyon has suggested it cannot be done. Further as you have intimated you are trying to change the default behaviour on a client computer and that IS invasive.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •