Solved

Copy Text To Clipboard

Posted on 2004-09-17
8
390 Views
Last Modified: 2007-12-19
I need to copy data from a Text Box to the Clipboard I know about
     Clipboard.SetText TextValue
However I need to do this in Access VBA and do not want to use a DLL or OCX Because I need this to be accessible to a lot of users on a shared drive who may or may not have the dll
0
Comment
Question by:davidtrina
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 13

Accepted Solution

by:
Michael_D earned 35 total points
ID: 12087771
Try :

Application.RunCommand acCmdCopy
Application.RunCommand acCmdPaste


Hope it helps.
0
 
LVL 3

Expert Comment

by:aParser
ID: 12087784
You might look at PAQ Q_20132577.html

There is code there to use the SendMessage API to copy selected text to the clipboard.  I don't think it allows you to send text without selecting it first.  The PAQ commenters also assert that there is no native way to access the clipboard inside VBA.

I also came across the Forms Library in a Google search. http://www.cpearson.com/excel/clipboar.htm

However this makes reference to a DLL.  While it should come with VBA, I didn't find it on my machine.  Also, Microsoft has a KB on it that basically says that the DLL is not freely redistributable; you must own a (Microsoft) product that installs it.  That may be tru in your environment and be what you need.

http://support.microsoft.com/default.aspx?kbid=224305

Hope this helps.
0
 
LVL 3

Expert Comment

by:aParser
ID: 12087794
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12087944
Just to give a more complete answer to Michael_Ds submission, you need to select the text in the textbox before using the copy command:

    Private Sub Command2_click()
        Text0.SetFocus
        Text0.Text = fileContents
        Text0.SelStart = 0
        Text0.SelLength = Len(Text0.Text)
        DoCmd.RunCommand acCmdCopy
    End Sub

Regards,

Idle_Mind
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12089491
Idle_Mind: You are always give "complete answer" :)
But I think that experts should give only an idea how to do something. Sometime it helps better then "complete answer".  
If it dosent help then try to help more.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12089583
You are going to get 50/50 split on whether a "Complete Answer" is better than an "outline answer" or a vague "use this command answer".

It really all depends on the author of the question.   Some can fill in the gaps...others can't.  If an author specifically says, "give me an idea of where to look and I can figure out the rest" then I won't give a "complete answer".  Otherwise, I give as detailed an answer as I can so that the author can choose how much of that information they need or don't need.  But by giving the author a working solution, they can usually see how to apply it their particular problem.

I did give your "correct answer" credit.  If davidtrina is experienced enough to know how to implement the command

    DoCmd.RunCommand acCmdCopy

without further assitance, then he/she will ignore my answer and accept yours since I "stated the obvious" and they already knew how to do it.  Just because the author didn't figure out how to solve the problem by themself doesn't mean they haven't learned anything.

Regards,

Idle_Mind
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12089766
You dont understand me correct! I dont care about points, I dont need them. You are absolutely right: all depends on the author of question. But it difficult to ignore full answer when it given. and there no more "brain" activity needed. In this particular question author said that he knows how to use  "Clipboard.SetText TextValue" . He also knows that VBA doesn't have Clippboard Object. By my opinion this user able to figure out by himself how to use Application.RunCommand if he knows that this command exists. Correct me if i am wrong.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12089857
>> But it difficult to ignore full answer when it given.

So give full answers!

If people didn't want them, they would accept "brain teaser" answers more often than "complete answers".

...but as you stated yourself, this isn't the case.  Most authors clearly state when they don't want detailed answers, and would like to see a generalized discussion instead.

If you want to increase peoples "brain activity" then try posting here:
http://www.experts-exchange.com/Miscellaneous/Puzzles_Riddles/

/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|

davidtrina,

If you end up using the DoCmd.RunCommand acCmdCopy approach, please accept Michael_Ds submission and not mine.

/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|

Regards,
   =)
Idle_Mind
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

631 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