[RESOLVED] How do I tell if the Clipboard is Clear? (No data in clipboard)
Hello there everyone!
How do I tell if the Clipboard has any data stored in it?
Thank you and have a great day!
Stilekid007
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
VB Code:
If Len(Clipboard.GetText) = 0 Then
MsgBox "Clipboard cleared"
Else
MsgBox Clipboard.GetText
End If
I think that will work good
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
Unless it's an object. You'd have to test both.
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
good point, would the same technique work?
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
Hey,
Thank you so much for your responses!
How would I test to see if it is an object?
Stilekid007
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
Here are the Clipboard objects (it can support one of each at the same time)
Quote:
Constant Description
vbCFLink Dynamic data exchange link.
vbCFText Text. Examples earlier in this chapter all use this format.
vbCFBitmap Bitmap.
vbCFMetafile Metafile.
vbCFDIB Device-independent bitmap.
vbCFPalette Color palette.
Here is how the menu_Paste does it:
VB Code:
Private Sub mnuPaste_Click ()
If TypeOf Screen.ActiveControl Is TextBox Then
Screen.ActiveControl.SelText = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
Screen.ActiveControl.Text = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is PictureBox _
Then
Screen.ActiveControl.Picture = _
Clipboard.GetData()
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
Screen.ActiveControl.AddItem Clipboard.GetText()
Else
' No action makes sense for the other controls.
End If
End Sub
I would think that you could test an object against Nothing to see if it's empty, but haven't tried it yet.
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
I don't understand what this code does.
I put it in a cmd button and nothing happens.
Is this supposed to check to see if the clipboard has data?
VB Code:
Private Sub mnuPaste_Click ()
If TypeOf Screen.ActiveControl Is TextBox Then
Screen.ActiveControl.SelText = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
Screen.ActiveControl.Text = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is PictureBox _
Then
Screen.ActiveControl.Picture = _
Clipboard.GetData()
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
Screen.ActiveControl.AddItem Clipboard.GetText()
Else
' No action makes sense for the other controls.
End If
End Sub
Thank you!
Stilekid007
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
Here, this will tell you if anything is stored in the clipboard
VB Code:
Option Explicit
Private Sub Form_Load()
If GetClipData = True Then MsgBox "Clipboard Full!"
End Sub
Private Function GetClipData() As Boolean
Dim x As Variant
x = Clipboard.GetData
If x <> 0 Or _
Len(Clipboard.GetText) <> 0 Then
GetClipData = True
End If
End Function
Re: How do I tell if the Clipboard is Clear? (No data in clipboard)
Ok, cool!
Thank you to the both of you for your help and code!
It works great!
Stilekid007