Open inline object in Excel with VBA

In ms office document I pasted / inserted an external document (object) (PDF in my case).

After opening the document, when I click on the PDF object icon, it opens the PDF file embedded in it.

Using VBA / Macro I want to do the same where I need to run a macro and it will open the embedded PDF file (without clicking on ICON PDF).

Is it possible?

Thanks,

+4
source share
2 answers

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 - 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

" 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
+5

, , :

Excel

Sheets("Sheet1").OLEObjects("Object 1").Activate

ActiveDocument.InlineShapes(1).OLEFormat.Open
+3

Source: https://habr.com/ru/post/1621850/


All Articles