簡體   English   中英

Excel中的“ My.Computer.Clipboard”對象

[英]“My.Computer.Clipboard” object in Excel

有誰知道如何在Excel中使用“ My.Computer.Clipboard”對象。 我已經去過工具->參考文獻,嘗試了幾乎所有參考文獻。 我想使用類似的代碼

If My.Computer.Clipboard.ContainsImage() Then
      Dim grabpicture As System.Drawing.Image
      grabpicture = My.Computer.Clipboard.GetImage()
      picturebox1.Image = grabpicture
End If

https://docs.microsoft.com/en-us/dotnet/visual-basic/developing-apps/programming/computer-resources/storing-data-to-and-reading-from-the-clipboard

謝謝

在模塊中,放置以下代碼(或與測試代碼位於同一模塊中):

Option Explicit

#If Win64 Then
    Public Declare PtrSafe Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Long) As Long
#Else
    Public Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Long) As Long
#End If

然后,您可以通過以下代碼進行測試。

If IsClipboardFormatAvailable(2) <> 0 Or IsClipboardFormatAvailable(14) <> 0 Then ...

注意:14用於圖元文件,2用於位圖。

注意2:這適用於64位和32位Excel。

注意3:用於查找文本是否存在: if IsClipboardFormatAvailable(1)<>0 then ...

為了將數據(圖像)從剪貼板傳遞到Image控件(我想是在用戶Me.Image1.Picture = PastePicture ),請使用Me.Image1.Picture = PastePicture ,您也可以通過Google-ing“ ModPastePicture”找到其代碼,因為這不是適用於vba的方法。 這比將圖片保存到磁盤再將其重新加載到控制映像中要快得多。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM