Results 1 to 6 of 6

Thread: send to clipboard?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    I have a form with a text box and a command button.

    What would the code look like in order to have the contents of the text box get sent to the clipboard when I click on the command button?

    Thanks for your help..

    Dan

  2. #2
    Guest
    Code:
    Private Sub Command1_Click()
        Clipboard.SetText Text1
    End Sub

  3. #3
    Guest
    Dennis, your code will copy to the clipboard, but what if the user has not selected anything from the textbox to be copied?

    Code:
    Private Sub Command1_Click()
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1)
    Clipboard.SetText Text1.SelText
    End Sub

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Actually, both of your guy's code worked great... However, there is something really strange going on..

    When I paste the text that I copied with both of your guy's code into Notepad, it's fine.. But when i paste it into VB or any other program, such as Word, it actually pastes the code. So for example, when I past it into VB or Word, I get:

    Text1.SelStart = 0
    Text1.SelLength = Len(Text1)
    Clipboard.SetText Text1.SelText

    Instead of:

    <contents of Text1>

    Any idea as to why this is happening? Unfortunatley, I'm not using this to be able to paste into Notepad, so it's gonna be a problem..

    Thanks again,

    Dan

  5. #5
    Guest
    it isnt pasting the code,
    for some reason Vb and MS word isnt picking up the text that was copied with the program, it is recognizing the previous clipboard text,
    try copying

    Dennis is the coolest person in the world
    then use the code to copy something in Text1.
    when you paste into VB or word you will get

    Dennis is the coolest person in the world

    I dont know why it happens though.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Problem solved...

    Code:
    Clipboard.Clear 'clear clipboard of previous copy
    Clipboard.SetText Text1

Posting Permissions

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



Click Here to Expand Forum to Full Width