これは単なるコメントです(stackeoverflowはまだ私にプロッパの方法をコメントさせません)。
おそらく、いくつかのAPIを使いたいと思うかもしれません。
私はずっと前に(MS Wordを不正行為する方法を探して)これをプレイしました。コンテンツタイプの正しいID(純粋なものなど)を入力する限り、クリップボードに任意のコンテンツを保存できることを覚えていますテキスト、整形されたテキスト、、htmlなど)。コンテンツを保存した後、適切なタイプのコンテンツを貼り付けるために、それぞれのAPI関数を使用する必要があります。
私は期待どおりに進歩しなかったし、時間もなかったので、私はその考えを断念しました。 MSDNのAPI呼び出しを参照してください(私は今ここでそれを持っていません、そうでなければすぐにあなたに与えます)。
EDIT:コードが見つかりました。以下のコードはすべてモジュールに保存する必要があります:
' 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 & Chr$(0))
If (wFormat > &HC000&) 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&)) Then
' If (OpenClipboard(hWndOwner)) Then
' Check if this data format is available:
If (IsClipboardFormatAvailable(lFormatID) <> 0) Then
' Get the memory handle to the data:
hMem = GetClipboardData(lFormatID)
If (hMem <> 0) Then
' Get the size of this memory block:
lSize = GlobalSize(hMem)
If (lSize > 0) Then
' Get a pointer to the memory:
lPtr = GlobalLock(hMem)
If (lPtr <> 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
私はちょうどあなたがクリップボードを使用できないと言われたことに気付きました。ご面倒をおかけしてすみません。私は私の投稿を削除しようとしていましたが、質問をより慎重に読むように私に思い出させるのが良い方法だと思います。 – Oneide