Closed Thread
Results 1 to 12 of 12

Button to copy data

  1. #1
    Forum Contributor
    Join Date
    07-26-2007
    MS-Off Ver
    2007
    Posts
    102

    Button to copy data

    I have a user form which has a field txtA . I would like to add a button next to this field which when pushed will copy the contents of txtA to the clipboard so that it can be pasted into anoth application.

    Any help would be extremely helpful.
    Last edited by jcarstens; 09-25-2009 at 12:37 PM.

  2. #2
    Forum Contributor
    Join Date
    07-28-2009
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Button to copy data

    you will get better results if you upload the file.

  3. #3
    Forum Contributor
    Join Date
    07-28-2009
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Button to copy data

    if you insert a button insert
    Please Login or Register  to view this content.
    I can get this to work, but i still have to highlight the text that has been entered into TextBox1 which seems to be counter productive. I don't know what the macro script would be to select the text entered into TextBox1 to copy it.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Button to copy data

    Place this code in your button, remember to make sure that the TextBox name is correct
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Contributor
    Join Date
    07-26-2007
    MS-Off Ver
    2007
    Posts
    102

    Re: Button to copy data

    Thanks for the help. Its much appreciated!

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Button to copy data

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  7. #7
    Forum Contributor
    Join Date
    07-26-2007
    MS-Off Ver
    2007
    Posts
    102

    Re: Button to copy data

    I tried out the code and had it working for a second, but know I am experiencing errors. I put this in the attachment.
    Attached Files Attached Files

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

    Re: Button to copy data

    Hello jcarstens,

    Please update your User Profile to reflect which version or versions of Excel you are using. I had no idea you were using 2007 until I downloaded your zip file.
    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!)

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Button to copy data

    What errors are you experiencing. The form works fine.

    I entered text into the textbox, clicked the button then opened Notepad & pasted. Worked fine.

  10. #10
    Forum Contributor
    Join Date
    07-26-2007
    MS-Off Ver
    2007
    Posts
    102

    Re: Button to copy data

    Weird.Mine is working now too. Not sure what the problem was.

    Thanks for the help.

  11. #11
    Registered User
    Join Date
    09-15-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Microsoft 365
    Posts
    6

    Re: Button to copy data

    I have had success with the following approach, which uses some properties and methods of text boxes directly.

    I have wrapped the code in a subroutine. Use like this where "MyTextBox" is the actual name of the textbox containing the text to copy.

    CopyTextFromTextbox MyTextBox

    Please Login or Register  to view this content.
    The closest Microsoft reference to SelStart, SelLength, SetFocus I can find is the following

    http://msdn.microsoft.com/en-us/library/aa223162(v=office.11).aspx

    Hope that helps.

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

    Re: Button to copy data

    Hello Don Toto,

    Your suggestion is appreciated but In case you had not noticed, this thread is almost 2 years old.

Closed 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