• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 467
  • Last Modified:

Clipboard Problem

I've written a program that uses Clipboard.SetText to copy some text from a textbox. It copies it and my program can then paste that data into other text boxes. But when I try and paste the copied data into a different program, it pastes whatever was on the clipboard that wasn't set by my program.
I came to the conclusion that the Clipboard.SetText function must be a local function, that uses an internal app clipboard, not the system one. So how do I access the system clipboard from VB and paste text to it.

I'd appreciate a quick answer as I need to upgrade the program that some users have already downloaded.
3 Solutions
TheBakerAuthor Commented:
I've checked on MSDN and the Clipboard object IS the system one, so why can't Internet Explorer or Mozilla (the two browsers I've tried) access it?
You need to clear it before you call SetText.
TheBakerAuthor Commented:
Nope, that still hasn't done it. I clear the clipboard before setting the text but it still does the same thing!
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Sub Test
    Clipboard.SetText ("Hello World")
    MsgBox Clipboard.GetText
End Sub

Try running that sub, and then pasting the clipboard in a TEXT field.
clipboard has datatype settings and if you try pasting in some other datatype area, it may not paste.

this may help: http://msdn.microsoft.com/library/en-us/dnvbpj00/html/clip0002.asp
you have to clear the clipboard first

sub cmdClear_OnClick
   clipboard.settext text1.text
end sub
I suppose that what's happening is that you copy your data to the clipboard in you application, and then another running app (in the background or not) in other process override your data by saving his own data into the clipboard object.

close all other concurrently running  applications and run your app normally
The max u wud hav to do is:

Clipboard.SetText text1.text, vbCFText
TheBakerAuthor Commented:
I've tried clearing the data, but I still have the same problem. I can't close all other apps, because I  need a browser open (the text copied needs to be pasted into a web browser.

Would using the clipboard via the Windows API work? Could someone give me an example of how to copy text using the Windows API?
TheBakerAuthor Commented:
I can provide the compiled program if that will help. It is:
TheBakerAuthor Commented:
I've managed to solve the problem, I'm not sure quite what was happenning, but it's fixed now. Thanks to all that helped. I've split the points between those who's answers led me to the solution.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now