473,804 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy ONLY selected text to the windows clipboard

5 New Member
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_SetDa ta(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 10390
ADezii
8,834 Recognized Expert Expert
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_SetDa ta(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 New Member
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 Recognized Expert Specialist
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 Recognized Expert Expert
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
3079
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 be able to give me a bit of insight and for that I say Thank You in advance! this is what I have so far. private void CutText() {
13
2428
by: John | last post by:
Hi How can I implement cut or copy or paste in code? Thanks Regards
5
21040
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 windows explorer: when you do a right-click on a file and choose Copy, and than paste it somewhere in my application and vice versa.
2
2689
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 seems to work for me. A few people refer to txt.copy() txt.paste(), etc. I'm not sure if those are old functions, but they do not work for me. I've tried textbox1.selectall() - that works in selecting
17
5139
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 about 20 textboxes on the form). Also to ensure that the button can't get used if the cursor isn't in a textbox field. And to ensure the contents of the clipboard are "text" contents that have been cut/copied from one of the textboxes on the form. ...
6
1267
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() = _ CType(DObj.GetData(DataFormats.FileDrop), String()) This work fine but now I need to know if the user selected cut or copy when putting the file(s) on the clipboard.
1
2792
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 with setting up system wide hotkeys and with copying selected text if it was not an external application but could not find any info on how I might do the above.
11
9665
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
15445
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
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10337
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...
0
10082
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
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.