Solved

Blocking Format Changes on Paste

Posted on 2011-09-05
5
178 Views
Last Modified: 2012-05-12
This has always baffled me.  If you protect a sheet and disallow format changes, you cannot change the formatting of an unlocked cell - as expected.  But if you copy and paste, you can overwrite the formatting and even the validation.  That's a very nasty loophole.  I've always coded around this by intercepting the paste command, but I hate having to do this every time.  Is there another, easier way to solve this problem?

Mike

0
Comment
Question by:shacho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 42

Expert Comment

by:dlmille
ID: 36486779
I'm afraid some type of trap is necessary to prevent the user from copy/pasting.  We have to do the same thing with data validation cells, to avoid the restrictions being copied over.

Yogesh Gupta did a blog a while back http://www.yogeshguptaonline.com/2009/04/macros-in-excel-disable-cut-copy-paste.html to show us how to disable cut/copy/paste = which you could tailor to certain worksheets, or the entire book.  This approach may be more robust than others by preventing copy/paste rather than having to trap it and deal with it.  I must confess I've not tried it, but I'm in the same boat as you, having had to deal with this with data validation.  I will be trying it out next time I have to deal with this issue.

Perhaps its a bit easier on the coding than what you currently do?

Dave
0
 

Author Comment

by:shacho
ID: 36486866
It's approximately what I do now, though my version allows some controlled pasting by extracting data from the clipboard and depositing it as a type-appropriate string inside the cell or merged cell block.  That works, but the nasty pitfall in this approach is that it causes permanent changes to the interface that must be reversed or re-initialized whenever you switch active windows or close the file.  If the application crashes (and this happens as we all know) those changes stick.  Opening and closing the file will fix it, but that's not something an ordinary user will think to do if CTRL-V just suddenly stops working.
0
 
LVL 42

Expert Comment

by:dlmille
ID: 36490941
Agreed.

You might get a little more protection putting all this in a class module w/ application events...
0
 

Accepted Solution

by:
shacho earned 0 total points
ID: 36533907
Well, I guess there just is no other way to do it.  Oh well.  Excel isn't really intended for building forms.
0
 

Author Closing Comment

by:shacho
ID: 36555870
No solution reached
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question