How to Insert Picture without Clearing Clipboard
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 'Graphics - How to Insert Picture without Clearing Clipboard Option Explicit Public 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 Public Const WM_COPY = &H301 Public Function InsertPic() On Error Resume Next Dim strSaveClipboard As String Dim Pic As String Pic = "(Filename of Picture)" If Clipboard.GetFormat(vbCFText) = True Then strSaveClipboard = Clipboard.GetText Saved = True End If Clipboard.Clear Clipboard.SetData LoadPicture(Pic) SendMessage rtfText.hwnd, WM_PASTE, 0, vbNullString If Saved = True Then Clipboard.Clear Clipboard.SetText strSaveClipboard Else Clipboard.Clear End If End Function |