Paste Picture From PictureBox/Clipboard to Rich Text Box

When you will press the button,  the picture box's picture will be copied to the clipboard,  and from there will be pasted to the rich text box.


Add 1 Command Button (named Command1), 1 Rich Text Box (named RichTextBox1) and 1 Picture Box (named Picture1) to your form.
Add a picture to the Picture Box.

Module Code

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_PASTE = &H302

Form Code

Private Sub Command1_Click()
'the 2 code lines below copy the picture box's picture to the clipboard. if you will omit them,
'the picture that currently found in the clipboard will be copied to the rich text box.

    Clipboard.SetData Picture1.Picture
    SendMessage RichTextBox1.hwnd, WM_PASTE, 0, 0
End Sub

Go Back