+ Reply to Thread
Results 1 to 3 of 3

Preventing paste formats from other source

  1. #1
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Preventing paste formats from other source

    Hi all,
    I am working on a project where a registration is copied from an internal intranet page and entered into Excel
    Now if the user types this in or uses paste special values only then its fine.
    But if they use control V or paste or right click paste it wipes out the formatting and even locks the cell.
    There are only 4 cells on the sheet that are unlocked. These are either drop down boxes with lists in or just a cell for the registration.

    I have spent hours trying to find a solution to prevent the paste being available.

    I have some code which disables the paste options when the workbook is opened.
    When they click one of the unlocked cells (sheet password ="") it will check if there is anything in the clipboard and ask if they want to paste from the clipboard?

    No - it clears the clipboard and does nothing & prevents any paste options.
    Yes - it pastes the clipboard as text. (I had to also remove carriage returns as sometimes there are some on the intranet page.

    This works fine. But if you then leave the cell selected, go back to the intranet page again and then return, the paste option becomes enabled and allows the user to wipe out the conditional formatting and it also locks the cell which prevents further code from working.

    I cant seem to resolve this. Unfortunately Excel doesn't lose focus when you change a window so I cant use the workbook or worksheet deactivate event.

    Any solutions to prevent the user from doing this? Yes they should learn to use paste values only but we know that wont ever happen.
    The only other option I can see is to use an active X text box control. This will only allow control V to work and that will enter text only.

    Look forward to any suggestions.
    Attached Files Attached Files
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Preventing paste formats from other source

    Personally, I'd just add staging sheet where they can copy paste as they wish. Then use code to clean it up and transfer value(s) to the range (clearing everything from staging sheet when it's done).

    Depending on OS used and user's environment Clipboard API's can fail (ex: Windows 10 has some issues and also if user has 64 bit install of Excel your current code will cause issues).
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Preventing paste formats from other source

    My only option I can see is to either use a active X text box, or an input box.
    This limits the user to use control V only.

    Any other suggestions?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Preventing Duplicate copy paste
    By MASTERTIGER90 in forum Excel General
    Replies: 2
    Last Post: 06-22-2019, 11:12 AM
  2. [SOLVED] Preventing copy/paste into protected sheet
    By bgane in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 04-06-2017, 10:47 AM
  3. Copying Source Formats using Intersect ranges
    By pdalal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2016, 05:30 PM
  4. Replies: 4
    Last Post: 10-01-2014, 03:18 PM
  5. Preventing input validation paste bug without VBA
    By Scott H in forum Excel General
    Replies: 1
    Last Post: 08-27-2011, 10:13 AM
  6. Replies: 0
    Last Post: 10-04-2005, 02:05 PM
  7. Replies: 1
    Last Post: 09-30-2005, 05:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1