Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is just a comment (stackeoverflow doesn't let me comment the propper way yet).</p> <p>You probably could do it the way you want using some API.</p> <p>A long time ago I played with it (looking for some way to cheat MS Word) and I remember that you could store any content to the clipboard, as long as you enter the right id of the content type (like pure text, formated text, <strong>html</strong>, etc). After storing the content, you must use the respective API function to paste, again, the right type of content.</p> <p>I didn't make progress as fast as I expected, and I was short of time, so I abandoned the idea. If you would like to give it a chance, look up MSDN for the API calls (I don't have it here right now, otherwise I would give you right away).</p> <p>EDIT: I found the code. All the code below should be kept in a module:</p> <pre><code>' Clipboard functions: Private Declare Function OpenClipboard Lib "USER32" (ByVal hWnd As Long) As Long Private Declare Function CloseClipboard Lib "USER32" () As Long Private Declare Function GetClipboardData Lib "USER32" (ByVal wFormat As Long) As Long Private Declare Function IsClipboardFormatAvailable Lib "USER32" (ByVal wFormat As Long) As Long Private Declare Function RegisterClipboardFormat Lib "USER32" Alias "RegisterClipboardFormatA" (ByVal lpString As String) As Long ' Memory functions: Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Function GlobalSize Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long) Public Function GetClipboardIDForCustomFormat(ByVal sName As String) As Long Dim wFormat As Long wFormat = RegisterClipboardFormat(sName &amp; Chr$(0)) If (wFormat &gt; &amp;HC000&amp;) Then GetClipboardIDForCustomFormat = wFormat End If End Function Public Function GetClipboardDataAsString(ByVal lFormatID As Long) As String 'Public Function GetClipboardDataAsString(ByVal hWndOwner As Long, ByVal lFormatID As Long) As String Dim bData() As Byte Dim hMem As Long Dim lSize As Long Dim lPtr As Long ' Open the clipboard for access: If (OpenClipboard(0&amp;)) Then ' If (OpenClipboard(hWndOwner)) Then ' Check if this data format is available: If (IsClipboardFormatAvailable(lFormatID) &lt;&gt; 0) Then ' Get the memory handle to the data: hMem = GetClipboardData(lFormatID) If (hMem &lt;&gt; 0) Then ' Get the size of this memory block: lSize = GlobalSize(hMem) If (lSize &gt; 0) Then ' Get a pointer to the memory: lPtr = GlobalLock(hMem) If (lPtr &lt;&gt; 0) Then ' Resize the byte array to hold the data: ReDim bData(0 To lSize - 1) As Byte ' Copy from the pointer into the array: CopyMemory bData(0), ByVal lPtr, lSize ' Unlock the memory block: GlobalUnlock hMem ' Now return the data as a string: GetClipboardDataAsString = StrConv(bData, vbUnicode) End If End If End If End If CloseClipboard End If End Function </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload