Solved

Copy Text To Clipboard

Posted on 2004-09-17
8
371 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
  • 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
 
LVL 85

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 85

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 85

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 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

17 Experts available now in Live!

Get 1:1 Help Now