Results 1 to 5 of 5

Thread: Cut Copy Paste Text

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Post Cut Copy Paste Text

    The problems I am facing is that I need to know the characters which are highlighted for copying. I want to get them. Also I need to know how to paste characters since sending the keys does not work as pasting it works just like you were pressing the keys. I need to paste them, not send them.

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Cut Copy Paste Text

    Quote Originally Posted by lone_REBEL
    The problems I am facing is that I need to know the characters which are highlighted for copying. I want to get them. Also I need to know how to paste characters since sending the keys does not work as pasting it works just like you were pressing the keys. I need to paste them, not send them.
    not sure coping from where and past to where

    Below code copy selected text in text1 and past it in Text2
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    'Copy
    Me.Text1.SelStart = 2
    Me.Text1.SelLength = 5
    VB.Clipboard.Clear
    VB.Clipboard.SetText Me.Text1.SelText
    
    'Past
    Me.Text2.Text = VB.Clipboard.GetText
    VB.Clipboard.Clear
    
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Post Explaination

    I need my code to work globally, for all applications not just my own form. I mean it should work O.K. to get the highlighted text in a notepad window and pasting it in a wordpad window. Bringing the window to front or giving it the focus is not the problem.
    I mean I create a hotkey for my app and whenever that hotkey is pressed while any window is in the focus, my program should tell what text has been highlighted and if another hotkey is pressed, it should paste the text in the clipboard. Creating the hotkeys is not required in this problem, only getting and pasting the selected text.

  4. #4
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Cut Copy Paste Text

    You can use,

    Code:
    Clipboard.clear
    SendMessage (Notepad Edit Window Handle here, WM_COPY,0,0)
    This will copy the selected text in the note pad to clipboard

    Not sure hwo to past in to the word doucment.
    but to past in to a text box, as stated in my first post,
    me.text1.text=clipboard.gettext


  5. #5
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Cut Copy Paste Text

    i forget,
    you can also use the following on external applications. but not sure about word.
    Code:
    SendMessage (destination edit / text box handle here,wm_past,0,0)
    above code will past the clipboard text in to a text or edit control window in your own or in an external application.

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