gpt4 book ai didi

excel - 检查剪贴板是否为图像

转载 作者:行者123 更新时间:2023-12-03 02:31:15 25 4
gpt4 key购买 nike

我正在尝试将 .PDF 复制到 Word 和 Excel 中(此处仅显示 Word 的代码,Excel 的代码几乎相同)。为此,我使用 IrfranView.PDF 转换为图像,但它仅有时有效,不知道为什么?我想我需要等待一段时间才能粘贴它。

有没有办法可以检查剪贴板是否包含图像并继续循环,直到它包含图像或计时器超过 1.5 秒?

'Add pdf of drawing to word file
If zFile <> "" Then
Dim oData As New MSForms.DataObject
oData.SetText Text:="Empty" 'Clear
oData.PutInClipboard 'take in the clipboard to empty it
Shell "C:\Program Files (x86)\IrfanView\i_view32.exe " & zFile _
& "/clipcopy /convert=" & Environ("AppData") _
& "\IrfanView\ConverTemp.jpg /jpgq=100"
Sleep (1000)
copyImg = Not oData.GetFormat(1)
If copyImg Then
Documents(docLogSkjema).Activate
Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakNextPage
With Selection.PageSetup
.Orientation = wdOrientLandscape
.PageWidth = CentimetersToPoints(42)
.PageHeight = CentimetersToPoints(29.7)
End With
With Selection.Sections(1).Headers(wdHeaderFooterPrimary)
.LinkToPrevious = False
.Range.Delete
.LinkToPrevious = False
.Range.Delete
End With
Selection.Paste
End If
End If

最佳答案

这里是检查剪贴板上是否有图片的代码,在单独的模块中使用此代码:

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

Function Is_Pic_in_Clipboard() As Boolean
If IsClipboardFormatAvailable(2)<>0 Or IsClipboardFormatAvailable(14)<>0 Then _
Is_Pic_in_Clipboard = True '2=BMP, 14=JPEG
End Function

然后,判断是否有图片,使用If Is_Pic_in_Clipboard then ...

<小时/>

更多信息:

关于excel - 检查剪贴板是否为图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42853007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com