# using Clipboard in VB6



## lamstaldy (Dec 16, 2001)

Is there an easy way to check and see if there is anything in the Clipboard? Right now I'm setting the contents of Clipboard to an invisible text box and then checking the length of the text box. If the length of the text box is 0 then the Clipboard was empty. This works, but it seems like there should be a more straight forward way to do this.

P.S. any chance we could get a smilie with a gun to its head, for those times when we are really stressed.


----------



## Mosaic1 (Aug 17, 2001)

What kind of data are you checking for on the Clipboard? Here's a quick example of checking for text.


```
Dim A As Integer
   If Clipboard.GetFormat(vbCFText) Then A = 1
      If A = 1 Then MsgBox "Clipboard contains text"
```
 or

```
Dim B as String
Dim A As Integer
B = Clipboard.GetText
        If B = "" Then
         Else: A = 1

 End If

 If A = 1 then Whatever action you wanted to take
```


----------



## lamstaldy (Dec 16, 2001)

I'm looking for any text to be in the clipboard. I have a Paste command in the Edit menu. When some one clicks on the Edit I want the Paste command to be disabled if the clipboard is empty. In your first example what is (vbCFText)? Does that return True if the clipboard text is in a certain format? Or True for any text?
I know this is a diferent subject, but have you ever used Outlook in a VB app? That's my next step in this project so I'm sure I'll some questions.
Mosaic1 thanks again for helping me out.


----------



## Mosaic1 (Aug 17, 2001)

When checking for Text. The data type is text only. For example, I copy a bitmap to the clipboard and open Notepad. Paste is unavailable. But if I open wordpad, paste is available. It is checking for the particular types of data. I think that wouod be the same in your program. 

If you go to help and search for ClipBoard, you'll see all the various data types you can have the program look for .

If you don't have help, post back and I'll get you a list.

It really depends on what your program does and what type of data you want it to paste.


----------



## lamstaldy (Dec 16, 2001)

I am just looking for text so that should work great. I'll check out the help CD tomorrow just to see what else is available. Thanks again Mosaic1.


----------



## Mosaic1 (Aug 17, 2001)

I read my last answer again and it sounds confusing. The return is true is text exists and false if not. It is perfect for what you want to do. If true enable paste. If false, disable paste.

Actually, I didn't need to assign to a variable A. The default is true. I am still learning. That was overkill. Sorry.

The truth is I am dabbling in this. I am not advanced in the least. I am learning bit by bit in my spare time. I have not used any Office VBA.


----------



## lamstaldy (Dec 16, 2001)

I understood your answer, and your suggestion worked fine. This is what I ended up with:


If (Clipboard.GetFormat(vbCFText)) Then
mnuPaste.Enabled = True
Else
mnuPaste.Enabled = False
End If

I too have been trying to learn on my own. I think I really need to install the help files, but they take up so much room on the hard drive. You've been able to help me with all my problems so you're an expert in my book! Thanks again, and I hope I can return the favor someday.


----------

