Solved

Clipboard Problem

Posted on 2003-10-26
10
442 Views
Last Modified: 2013-11-25
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.
0
Comment
Question by:TheBaker
10 Comments
 
LVL 1

Author Comment

by:TheBaker
ID: 9622697
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?
0
 
LVL 3

Accepted Solution

by:
monkesdb earned 34 total points
ID: 9622986
You need to clear it before you call SetText.
0
 
LVL 1

Author Comment

by:TheBaker
ID: 9623023
Nope, that still hasn't done it. I clear the clipboard before setting the text but it still does the same thing!
0
 
LVL 8

Assisted Solution

by:fozylet
fozylet earned 33 total points
ID: 9623664
Sub Test
    Clipboard.Clear
    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
0
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9624894
you have to clear the clipboard first

sub cmdClear_OnClick
   clipboard.clear
   clipboard.settext text1.text
end sub
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Assisted Solution

by:BUCHAS
BUCHAS earned 33 total points
ID: 9624964
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
0
 
LVL 7

Expert Comment

by:_agj_
ID: 9625092
The max u wud hav to do is:

Clipboard.Clear
Clipboard.SetText text1.text, vbCFText
0
 
LVL 1

Author Comment

by:TheBaker
ID: 9625482
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?
0
 
LVL 1

Author Comment

by:TheBaker
ID: 9625498
I can provide the compiled program if that will help. It is:
http://freehost14.websamba.com:81/NDifference/content/smileyxtra_setup.exe
0
 
LVL 1

Author Comment

by:TheBaker
ID: 9625627
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now