How to prevent pasting an image into textbox. I understand that i have to check a clipboard and if data is an image then give a msg box that user can not paste image to textbox. I need a full code.
If Clipboard.GetFormat(vbCFText) Then
' code here to paste text
End If
So if the clipboard does have text in it, the statement will return true.
To get a list of the different constants, type vbCR into the window then press CTRL-Space. This will show you all of the different Clipboard Format ( CF ) constants.
I got this part. The other problem raised.
When I copy from word doc the doc that contains not only text or only image, that contains both things at ones text and image at the same time, then the problem occures. When I debug my program it skips both statements:
If Clipboard.GetFormat(vbCFBitmap) Then
ElseIf Clipboard.GetFormat(vbCFText) Then
Can you not extract just the text from the Clipboard?
This worked for me (note the lack of error handling!!)
Code:
Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = Data.GetData(vbCFText)' get only the text
End Sub
I managed to Copy'n Paste google's homepage without a problem, getting just the text, albeit the formatting was screwy, but you'd have to expect that!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.