Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent pasting image into textbox

Status
Not open for further replies.

YanaD

Programmer
Mar 22, 2001
38
0
0
US
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.
 
Use this when checking if it's text or not:

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.

Hope this helps,

Robert
 
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

How may i check the format at this point?
 
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!

Hope This Helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top