LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default copy text to clipboard

Perfect. Thank you very much!

"Chip Pearson" wrote:

In VBA, go to the Tools menu, choose References, and put a check next
to "Microsoft Forms 2.0 Object Library" (or, just add a UserForm to
the project and then delete the UserForm). Then, use code like


Sub PutToClipboard(S As String)
Dim DataObj As New MSForms.DataObject
DataObj.SetText S
DataObj.PutInClipboard
End Sub

Function GetFromClipboard()
Dim DataObj As New MSForms.DataObject
DataObj.GetFromClipboard
GetFromClipboard = DataObj.GetText
End Function

You would then use these functions like

Sub AAA()
Dim S As String
PutToClipboard "hello"
S = GetFromClipboard
MsgBox S
End Sub

See http://www.cpearson.com/excel/Clipboard.aspx for more details.


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Thu, 27 Aug 2009 05:57:01 -0700, Mitch Powell
wrote:

I need to copy some text to the clipboard using vba so that is will be
available in another application. For various reasons, I cannot use the
native Excel Copy function in this case. I can find no way to do this.
Surely I am missing something obvious.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy a set bit of text to the clipboard? StargateFanNotAtHome[_2_] Excel Programming 3 August 10th 09 04:05 AM
copy hyperlink to clipboard [email protected] Excel Programming 1 December 3rd 08 08:12 PM
copy to clipboard greg Excel Programming 2 September 19th 08 07:20 PM
Transfer clipboard from Task pane clipboard(office?) content to Excel (windows?) clipboard? tskogstrom Excel Programming 2 March 6th 07 12:50 PM
Copy from clipboard? G Lam[_2_] Excel Programming 1 November 24th 04 09:05 AM


All times are GMT +1. The time now is 04:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"