Trapping non-text paste into richtextbox
Posted on 2002-07-30
I have a richtextbox which i dont want users to be able to paste anything but text into (ie. files, images etc..) i have the following code which detects the paste action within my textbox but whatever i try to do it still pastes the file into it.
if i try pasting a piece of text then the relevant msgbox appears but if i paste an object such as a file it doesnt display a msgbox and pastes the file into the box.
Private Sub Form_KeyUp(KeyAscii As Integer, Shift As Integer)
If KeyAscii = (vbKeyV And Shift = 2) Then
If Clipboard.GetFormat(1) <> True Then
MsgBox ("YOU ARE PASTING A FILE")
KeyAscii = 0
MsgBox ("YOU ARE PASTING TEXT")
i have disabled OLEdrag. I am only using a richtextbox so i can colour certain pieces of text red