我创建了一个宏,该宏将从模板中添加页面,并将插入图像,Office支持的文件类型以及插入PDF。当我在桌面上使用此宏时,图像以及PDF都将插入到我的文档中并显示图片。
当我在Surface Pro上使用宏时,图像仍会出现,但是OLE对象(PDF)仅显示图标,而不显示实际图片本身。我将在底部附加代码,但是不幸的是我对执行该操作感到茫然。我试图将PDF作为图像插入,但是Office不支持该功能(我相信已删除2010/2013)。
我还试图在with语句中添加OLEtypeAllows = acOLEEmbedded。我希望避免仅将链接放入文档中,因为文档将被移动,并且我希望发送一个文件而不是多个文件。
代码
Set oleobj = ActiveSheet.OLEObjects.Add(Filename:=txtFileName, Link:=False, DisplayAsIcon:=False)
With oleobj
'These are commented out as it's stuff I've tried unsuccessfully
'OLEtypeallows = acOLEEmbedded
'Action = acOLECreateEmbed
oleobj.Top = rng.Top
oleobj.Left = rng.Left
'inserts the image to the correct location
If oleobj.Width > oleobj.Height Then
oleobj.Width = 545
oleobj.Left = (570 - oleobj.Width) / 2
oleobj.Top = oleobj.Top + 2
'Centers the image
Else
oleobj.Height = 625
oleobj.Left = (550 - oleobj.Width) / 2
oleobj.Top = oleobj.Top + 2
End If
End With