+ Reply to Thread
Results 1 to 4 of 4

How to copy to clipboard?

  1. #1
    Registered User
    Join Date
    04-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    85

    How to copy to clipboard?

    I recorded the following macro:

    Range("G22:P33").Select
    Selection.Copy

    ... so as to copy data to a clipboard to then paste elsewhere, but the data
    doesn't stay on the clipboard once the macro stops running (I linked it to a
    button.) Am I missing an extra command or something? Thanks in advance.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: How to copy to clipboard?

    Hi jp001,

    quick forum search result

    http://www.excelforum.com/excel-prog...copy-data.html
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How to copy to clipboard?

    Hello jp001,

    Windows protocol requires that an object release the Clipboard once it is finished with the clipboard or the object has gone out of scope. That is why your data disappeared. The clipboard contents need to be stored in memory or pasted to a worksheet before the macro code has finished. The DataObject mentioned in the link will help you keep the clipboard "alive". Remember that once data is placed on the clipboard, no other programs can use it until it is released by clearing or pasting the data.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    04-08-2009
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: How to copy to clipboard?

    Thanks for the above, but it seems my code works fine after all. I just forgot to link it to the right module when I changed it's name.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1