473,722 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copying txtbox contents to the clipboard

I have an Access97 application whose form contains many text boxes.
What do I have to do in order to copy the contents of one of these text
boxes to the clipboard? I want to do this so I can then paste from the
clipboard to Word, Notepad, etc.

I know about the SetClipboardDat a function, but I really can't figure
out how it works. It's supposed to be used in conjunction with the
OpenClipboard function, I think.

If anybody knows, please let me know. Please be as specific as possible
in your answer, giving code samples.

Thank You.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
16 12469
I have yet to see any situations where what you describe would be necessary to
do under code control (though code examples to exist). Is there some reason
the user cannot simply select the text in the control and copy it? If the
control is not editable, simply make it Locked to prevent editing, and
perhaps, make it Tab Stop = No, so the user can only select it using the
mouse, and not be confused by having it in the tab order.

Here's a link to a code example if you truly do have a need for it:
http://www.mvps.org/access/api/api0049.htm

On 31 Dec 2003 06:19:41 GMT, DataBard007 <an*******@devd ex.com> wrote:
I have an Access97 application whose form contains many text boxes.
What do I have to do in order to copy the contents of one of these text
boxes to the clipboard? I want to do this so I can then paste from the
clipboard to Word, Notepad, etc.

I know about the SetClipboardDat a function, but I really can't figure
out how it works. It's supposed to be used in conjunction with the
OpenClipboar d function, I think.

If anybody knows, please let me know. Please be as specific as possible
in your answer, giving code samples.

Thank You.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 12 '05 #2
To copy the contents of just one control (such as "Surname") use:
Me.Surname.SetF ocus
RunCommand acCmdCopy

If you want something more powerful, see:
http://www.mvps.org/access/api/api0049.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"DataBard00 7" <an*******@devd ex.com> wrote in message
news:3f******** *************@n ews.frii.net...
I have an Access97 application whose form contains many text boxes.
What do I have to do in order to copy the contents of one of these text
boxes to the clipboard? I want to do this so I can then paste from the
clipboard to Word, Notepad, etc.

I know about the SetClipboardDat a function, but I really can't figure
out how it works. It's supposed to be used in conjunction with the
OpenClipboard function, I think.

If anybody knows, please let me know. Please be as specific as possible
in your answer, giving code samples.

Nov 12 '05 #3
Mr. Jorgensen:

I want to be able to copy to the clipboard simply by clicking on the
txtbox, rather than having to select the whole item, and press ctrl + c.
It's a matter of simplicity for the user, that's all.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4
Allen wrote:

To copy the contents of just one control (such as "Surname") use:
Me.Surname.SetF ocus
RunCommand acCmdCopy
Thanks Allen, but I'm getting the following error when I use your code
in the Click event of one of the text boxes:

Runtime Error 2046
The Command or Action copy isn't available now.
You may be in a read only database or an unconverted database from an
earlier version of the application.
The type of object the application applies to isn't currently selected
or isn't in the active view.
Use only those commands and macro actions that are currently available
for this database.

It is neither a RO database nor an unconverted database. So I don't
understand. Please give me some ideas.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
On 31 Dec 2003 07:39:40 GMT, DataBard007 <an*******@devd ex.com> wrote:
Mr. Jorgensen:

I want to be able to copy to the clipboard simply by clicking on the
txtbox, rather than having to select the whole item, and press ctrl + c.
It's a matter of simplicity for the user, that's all.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


IMO, it's inconsiderate to the user to make it so easy to accidentally
overwrite the existing contents of the clipboard. I do see, however, how it
might be nice to have a small button next to the control to copy to the
clipboard.

Based on your reply to Allan, it sounds as if the problem is that no text is
selected in the control when you are trying to copy it. This is normal when
you click into a control with the mouse rather than navigating to it using the
keyboard, the carat is placed at the point where yu click, and no text is
highlighted.

You could use code to select all the the text in the control before you try to
copy it to the clipboard, but I think using the button as I suggest would also
solve the problem quite simply. When the user clicks the button, set the
focus to the text control, and then copy the text. The text in the control
will have been selected following the .SetFocus event.
Nov 12 '05 #6
Allen:

I know what's wrong now. I thought I could just click in the text box
and using a Click event procedure, get the contents of the box to copy
to the clipboard. But that doesn't work. You actually have to select
the contents with the mouse first. But I don't want to have to do that.
I want a simple click event to do all the work. Will the code sample
you referred me to allow me to do that? Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #7
Mr. Jorgensen:

I don't quite understand the code in the reference that you gave me. He
uses 11 api functions and 3 functions of his own design.

Do you think you could give me a brief, step by step explanation of what
each line is doing? I know that's a lot to explain, but I need to
understand it if I'm to implement it myself.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #8
Well, it sounds like it should be possible to make Allen's solution work for
you, so try doing battle with that first, and we'll battle with the API code
if necessary. I think you just probably need to make sure the text in the
control is highlighted before trying to copy it.

On 31 Dec 2003 08:09:47 GMT, DataBard007 <an*******@devd ex.com> wrote:
Mr. Jorgensen:

I don't quite understand the code in the reference that you gave me. He
uses 11 api functions and 3 functions of his own design.

Do you think you could give me a brief, step by step explanation of what
each line is doing? I know that's a lot to explain, but I need to
understand it if I'm to implement it myself.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 12 '05 #9
Check the SelStart and SelLength properties of the textbox. These will let
you select the text in the textbox, then do the copy.

Example:
Me.Surname.SetF ocus
Me.Surname.SelS tart = 0
Me.Surname.SelL ength = Len(Me.Surname. Text)
RunCommand acCmdCopy

--
Wayne Morgan
Microsoft Access MVP
"DataBard00 7" <an*******@devd ex.com> wrote in message
news:3f******** *************@n ews.frii.net...
Allen:

I know what's wrong now. I thought I could just click in the text box
and using a Click event procedure, get the contents of the box to copy
to the clipboard. But that doesn't work. You actually have to select
the contents with the mouse first. But I don't want to have to do that.
I want a simple click event to do all the work. Will the code sample
you referred me to allow me to do that? Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5700
by: Carl | last post by:
I'm trying to select, with the mouse, a cell within a flexgrid that I've created, and copying the contents of that cell to the clipboard. I've tried using the Mousecol and Mouserow properties to return the cell col and row index, but It doesn't seem to RETURN the cell ID but needs an argument identifying, seemingly the col and row repectively. Here's the test routine I set up just to see how the mousecol property worked but it genterates...
2
6908
by: Gey-Hong Gweon | last post by:
Is there a way to copy a PIL image to windows clipboard (as a dib image or a bitmap, I suppose)? What I would like to accomplish is to do a fast copy and paste of images from my python application to a windows application such as powerpoint. A slower way is to use files, which is what I am doing at the moment. Thanks in advance.
0
568
by: Ata | last post by:
Hello, I am trying to copy the contents of the output of SQL Reporting Services to a PowerPoint slide. For this, I am using SQL Reporting Services to obtain an IMAGE stream, which I paste to the Windows clipboard. Then, using automation, I am trying to copy this information from the clipboard to a PowerPoint slide. However, I get an error at slide.Shapes.PasteSpecial. I am able create a System.Drawing.Bitmap object from the memory...
1
4014
by: John | last post by:
Hi How can I copy some fields to clipboard so they can be pasted into other applications? Thanks Regards
8
16244
by: John Smith | last post by:
Hi folks, I know how to place text into the user's clipboard: Clipboard.SetDataObject("My Copied Text"); but how do I place a file in there? So, if I have a file C:\test.txt, how can I place that file into the user's clipboard so that they can later paste it into explorer? Thanks!!!
9
2128
by: Christian Blackburn | last post by:
Hi Gang, I don't know what to make of all of this, but I'm having nothing, but trouble copying data to the clipboard which should be the easiest thing in the world. The only systems I can get this to not crash on is my development system w/ VB 2003 installed and Windows NT 4. My development system is Windows 2000 Pro, but if I try using the clipboard on Win2K Pro system that doesn't have VB 2003 installed it'll crash. The only...
2
1593
by: Just Me | last post by:
Dim iData As IDataObject = Clipboard.GetDataObject() Dim img As System.Drawing.Bitmap img = img.FromFile(ofd.FileName, True) Clipboard.SetDataObject(img) TextControl1.Paste() img.Dispose() : img = Nothing Clipboard.SetDataObject(iData) I want to insert an image and tried the above. I wanted to not disturb the clipboard and didn't know how to do that so I
19
8734
by: Jeff | last post by:
....working with visualweb.net 2005 and vb. ....trying to simply copy the contents from a textbox to the clipboard. I've looked at a large number of places on line and they give me various code, but it doesn't work. I'm apparently missing some type of declaration, and the code is diffent in visualweb.net than elsewhere. When I try the code below, it tells me that the "name clipboard is not declared"
0
1998
by: MathewJose | last post by:
Hi, I have a DatagridView in windows form.It has got a column which has some names that are populated from master table in database.Now i need to copy a set of data against these names. I tried to populate data to the first column from database and then tried to copy excel sheet data against each name but some exceptions are coming.It says "cannot programmaticaly add rows while using data bind". This is the code that i used for...
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9238
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.