在ms office文档中,我嵌入/插入了一个外部文档(对象)(在我的情况下为PDF).
打开文档后,当我单击PDF对象图标时,它会打开嵌入其中的PDF文件.
使用VBA/Macro我想做同样的事情,我必须运行一个宏,它将打开嵌入的PDF文件(不点击PDF图标).
可能吗?
谢谢,
Excel中:
你可以得到OLEObject
的形式OLEObjects
的Worksheet
.见OLEObjects
- https://msdn.microsoft.com/en-us/library/office/ff840244.aspx,OLEObject
- https://msdn.microsoft.com/en-us/library/office/ff838421.aspx,OLEObject
成员- HTTPS ://msdn.microsoft.com/EN-US/library/office/ff841208.aspx.
有一种方法Verb
有一个用于打开对象的动词.请参阅https://msdn.microsoft.com/EN-US/library/office/ff838827.aspx - Verb
s - https://msdn.microsoft.com/EN-US/library/office/ff820926.aspx
例:
Sub test() With ActiveSheet Set o = .OLEObjects("Objekt 1") o.Verb xlVerbOpen End With End Sub
"Objekt 1"是Excel工作表中对象的名称.对象必须位于活动工作表中.
字:
在Word中,它取决于嵌入的对象是在一个InlineShape
还是一个Shape
.而且没有OLEObjects
收藏品.所以你必须处理Shape.OLEFormat
.见InlineShapes
- https://msdn.microsoft.com/en-us/library/office/ff822592.aspx,Shapes
- https://msdn.microsoft.com/en-us/library/office/ff845240.aspx,Shape
- HTTPS: //msdn.microsoft.com/en-us/library/office/ff196943.aspx,OLEFormat
- https://msdn.microsoft.com/EN-US/library/office/ff197153.aspx.
例:
Sub test() With ActiveDocument Set oShape = .InlineShapes(1) 'The embedded object is the first InlineShape. 'Set oShape = .Shapes(1) 'The embedded object is the first Shape. Set oOLEFormat = oShape.OLEFormat oOLEFormat.Open End With End Sub