+ Reply to Thread
Results 1 to 5 of 5

VBA CopyText button

  1. #1
    Registered User
    Join Date
    02-10-2015
    Location
    Seattle, WA
    MS-Off Ver
    2013
    Posts
    10

    VBA CopyText button

    Hi, new here. I've had the best luck finding solutions on this site, but I can't seem to find one for this. Im' working a template and need to create a button that copies multiple text boxes from a user form into clipboard. I have an example here:

    Sub CommandButton1_Click()

    Dim MyData As New DataObject
    MyData.SetText TextBox2.Text
    MyData.PutInClipboard

    End Sub

    I know it's something easy I'm missing, can anyone help?!

  2. #2
    Registered User
    Join Date
    02-10-2015
    Location
    Seattle, WA
    MS-Off Ver
    2013
    Posts
    10

    Re: VBA CopyText button

    I tried changing the command a little to included textbox.copy and just do a copy/paste without explicitly moving the text to the clipboard. But that just ended with more errors, and at one point just crashed everything. Lol, any ideas?

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA CopyText button

    Are you using the clipboard only to transport this text from TextBox2 to somewhere? Where is the somewhere?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    02-10-2015
    Location
    Seattle, WA
    MS-Off Ver
    2013
    Posts
    10

    Re: VBA CopyText button

    Yeah the clipboard is really unnecessary. I just need to copy the text from the UserForm to a service desk ticketing system. The goal is to copy about 8 textboxes all at once, then paste the combination to a web based form.

  5. #5
    Registered User
    Join Date
    02-10-2015
    Location
    Seattle, WA
    MS-Off Ver
    2013
    Posts
    10

    Re: VBA CopyText button

    I tried adding a bit more to my textbox. I guess I'm trying to combine my original with:

    Private Sub TextBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)


    Dim myClipbd As New DataObject


    If TextBox2.Text <> "" Then
    With myClipbd
    .SetText TextBox2.Text
    .PutInClipboard
    End With

    Else: MsgBox "There is no text to copy. To enter text,click this textbox once."


    End If


    End Sub

    I'm not sure if I actually have to add a loop, something to scan all the textboxs and add them to a single clipboard.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Create running stopwatch/timer with 1 button (start/stop). No reset button.
    By leeroy2612 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-26-2021, 12:59 AM
  2. Replies: 0
    Last Post: 06-10-2014, 10:44 PM
  3. Button to copy specific cells to another sheet, lock button if cell has text
    By elmerg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2014, 02:10 AM
  4. [SOLVED] Linking together an Options Button and a command button inorder to load separate forms
    By emilyloz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2013, 02:10 PM
  5. Hide a picture button placed in all sheets using a option button (form control)
    By lagaranch in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-26-2012, 10:33 AM

Tags for this Thread

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