473,385 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Copy ONLY selected text to the windows clipboard

5
Hello,
I'm programming an application in MS Access 2003 / 2007 and would like to know how I can copy highlighted text to the windows clipboard?

I am now using a statement in combination with module "Call ClipBoard_SetData(Memo)" but this copies the whole 'memo' field.
I want to highlight text in the memo field and copy only that text to the clipboard.

What I really want is the VBA code for window's [Ctrl C] to copy selected text to the clipboard. I now use Ctrl C and then use a command to paste that text somewhere else and assign a category to it.

I want to make these 2 steps just 1. So in effect the code that runs behind the [Ctrl C] command in windows. I'll paste that in the VBA code and the user has to apply only one keystroke (or click).

Greetings,
ACF
Jun 19 '07 #1
4 10293
ADezii
8,834 Expert 8TB
Hello,
I'm programming an application in MS Access 2003 / 2007 and would like to know how I can copy highlighted text to the windows clipboard?

I am now using a statement in combination with module "Call ClipBoard_SetData(Memo)" but this copies the whole 'memo' field.
I want to highlight text in the memo field and copy only that text to the clipboard.

What I really want is the VBA code for window's [Ctrl C] to copy selected text to the clipboard. I now use Ctrl C and then use a command to paste that text somewhere else and assign a category to it.

I want to make these 2 steps just 1. So in effect the code that runs behind the [Ctrl C] command in windows. I'll paste that in the VBA code and the user has to apply only one keystroke (or click).

Greetings,
ACF
The following code will:

  1. Set Focus to the [LastName] Field.
  2. Select the entire Field's contents.
  3. Copy the entry in this Field to the Windows Clipboard.
  4. Is this what you are looking for?
Expand|Select|Wrap|Line Numbers
  1. Me![LastName].SetFocus
  2. Me![LastName].SelStart = 0
  3. Me![LastName].SelLength = Len(Me![LastName])
  4.  SendKeys "^c"
Jun 19 '07 #2
ACF
5
Thanks for your feedback, although code is for VB (will that work for VBA)?

But this will copy still the whole field


Expand|Select|Wrap|Line Numbers
  1. Me![LastName].SetFocus
  2. Me![LastName].SelStart = 0
  3. Me![LastName].SelLength = Len(Me![LastName])
  4. SendKeys "^c"
  5.  
I want the SelStart at the start of the text I've highlighted and SelLenght the number of characters I've highlighted (selected).

Is that possible?
Jun 19 '07 #3
FishVal
2,653 Expert 2GB
Thanks for your feedback, although code is for VB (will that work for VBA)?

But this will copy still the whole field

Expand|Select|Wrap|Line Numbers
  1. Me![LastName].SetFocus
  2. Me![LastName].SelStart = 0
  3. Me![LastName].SelLength = Len(Me![LastName])
  4. SendKeys "^c"
  5.  
I want the SelStart at the start of the text I've highlighted and SelLenght the number of characters I've highlighted (selected).

Is that possible?
Hi!

As far as I've have got it you want to implement the following functionality.
User selects a part of text in a textbox.
Then the textbox looses focus and the selected part remains highlighted.
Then something (e.g. button click) trigger copy of the selected text to clipboard.
Reentering to the textbox clears the selection.

Am I right? If so, I have a simple solution.
Jun 19 '07 #4
ADezii
8,834 Expert 8TB
Thanks for your feedback, although code is for VB (will that work for VBA)?

But this will copy still the whole field

Expand|Select|Wrap|Line Numbers
  1. Me![LastName].SetFocus
  2. Me![LastName].SelStart = 0
  3. Me![LastName].SelLength = Len(Me![LastName])
  4. SendKeys "^c"
  5.  
I want the SelStart at the start of the text I've highlighted and SelLenght the number of characters I've highlighted (selected).

Is that possible?
The code I gave you is generic and will work in VBA. Visual Basic (VB) has its own built-in Methods for moving Text and Graphics into and out of the Clipboard, namely: SetText and GetText for TEXT and SetData and GetData for GRAPHICS.
Jun 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: XmlAdoNewbie | last post by:
Hi All, I would like to put a method for copy, cut and paste into my application and this seems to be easy enough except that it's not working the way i would like it to, I thought someone might...
13
by: John | last post by:
Hi How can I implement cut or copy or paste in code? Thanks Regards
5
by: DraguVaso | last post by:
Hi, I'm looking for a way to Copy and Paste Files to the clipboard. I found a lot of articles to copy pieces of text and bitmaps etc, but nog whole files. Whay I need is like you have in...
2
by: Keith | last post by:
I'm trying to come up with a way to create a contextmenu that will do all the "standard" functions (cut, copy, paste, undo, etc). There seems to be a lot of information out there - but nothing...
17
by: Steve | last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user clicks on a toolbar button, the cut/copy/paste will work with whatever textbox the cursor is current located in (I have...
6
by: Fred | last post by:
I retreive files from the clipboard as below. Dim DObj As IDataObject = Clipboard.GetDataObject If DObj.GetDataPresent(DataFormats.FileDrop) Then Dim files As String() = _...
1
by: macrow | last post by:
Hi All, I was wondering if it was possible in vb.net to select text from an external application such as IE, then press a hotkey which would copy the contents to clipboard? I have no problems...
11
by: John | last post by:
Hi In a winform app I need to provide a menu with Cut, Copy and Paste options., What code do I use to accomplish cut, copy and paste features for fields on a winfrom? Thanks Regards
8
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.