我试图将一个 .PDF 文件复制到 Word 和 Excel 中(这里只是为了展示 Word 的代码,与 Excel 几乎相同)。为此,我使用 IrfranView 将 .PDF 转换为图像,但它有时候只能起作用,不知道为什么?我认为我需要等待一段时间再粘贴它。
有没有办法可以检查剪贴板是否包含图像,并循环保持直到存在或计时器超过 1.5 秒?
有没有办法可以检查剪贴板是否包含图像,并循环保持直到存在或计时器超过 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