How do I force paste action to strip out any hidden characters?

johnkrytus

Registered User.
Local time
Today, 07:35
Joined
Mar 7, 2013
Messages
91
My users do a fair bit of copy/paste from any number of sources.

How do I force the paste action to strip out any hidden characters? Now I realize that a return and a space are hidden characters, so how do I strip out everything but the ones that I want?
 
The only way that comes to mind is processing the input after the user pastes it. Like they would paste into a textbox, and then you'd process it from there. That processing would likely involve looping through the input character by character, keeping only valid characters.
 
That's certaily the only way I've ever seen that done.
 
My users do a fair bit of copy/paste from any number of sources.

How do I force the paste action to strip out any hidden characters? Now I realize that a return and a space are hidden characters, so how do I strip out everything but the ones that I want?

You'll need to trap the paste action with a Before_Update event and send it to some text parsing sub that will verify/modify the text.

best,
Jiri
 
To elaborate a bit, create a function that reads through each string character-by-character, and compare them with a list of 'approved' characters, including returns and line feeds. I've found it easiest to do by comparing the ASCII codes for each character against ranges of allowed ones.
 
Doesn't MS Word have a paste special function that does strips everything out and only pastes plain text? Is there no way to use that somehow?
 
Can you show us whatever reference you're reading regarding what the Paste Special can do?
If you know the data, why not parse out the things you don't need, as has been suggested?

There are a couple of functions at this link that may apply.
 
Control the formatting when you paste text

Well the first reason is that this thing will have overhead, and who likes to be slowed down when they are doing data entry?

Second, is that what I really want is just plain text. I can see problems sneaking in where odd characters are actually part of the paste that I want to keep and then we have to deal with always losing the weird data.

It just seemed to makes sense that the microsoft gods would give me a way to paste clean data without too much effort.
 

Users who are viewing this thread

Back
Top Bottom