Consulting

Results 1 to 2 of 2

Thread: Sleeper: Copy and paste in userform textbox

  1. #1
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location

    Sleeper: Copy and paste in userform textbox

    can anyone help with this please

    I want a button that mimics the shortcut ctrl - c and ctrl - v (copy/paste) that I can use to copy into a textbox on a userform from another application, is there an easy way to do this?

    Note: i dont want this to be via a right click on the mouse please and do need it to be code for a button

    Many Thanks

    Gibbo

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Hi Gibbo,
    I'm not sure what you mean. Do you already have something on the clipboard you want to put in a text box or do you have a value in another app somewhere you need to show in it?
    Normally, to assign it directly, you would use something like

    TextBox1.Text = Range("A1").Value
    in the Commandbutton_Click event
    If you're controlling another app, you might need to assign your value to a variable and pass that to the control (or make it public so the userform code can see it too)
    You can of course use the copy and paste methods e.g.

    Range("A1").Copy
    TextBox1.Paste
    the only thing you have to watch here is to maybe check the clipboard contents is a string or the textbox paste method will error. Also, as in the example here, you will probably get a paragraph character at the end which you might want to strip out
    K :-)

Posting Permissions

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