Get OLE Object Data Example (VBA)
This example shows how to get an OLE object's data.
'-----------------------------------
'
' Preconditions: Model document with an OLE
' object
on it is open.
'
' Postconditions: None
'
'------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swOleObj As SldWorks.SwOLEObject
Dim boolstatus As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
Set swSelMgr = swModel.SelectionManager
boolstatus = swModelDocExt.SelectByID2("Worksheet",
"OLEITEM", 0.2414446227929, 0.1453461331466, 0, False, 0, Nothing,
0)
Set swOleObj = swSelMgr.GetSelectedObject6(1,
0)
Debug.Print "Linked filename =
" & swOleObj.FileName
Debug.Print "Ole Object ClsID =
" & swOleObj.Clsid
Debug.Print "Ole Object IsLinked =
" & swOleObj.IsLinked
Debug.Print "Ole Object BufferSize = " &
swOleObj.BufferSize
Debug.Print "Ole Object Aspect =
" & swOleObj.Aspect
End Sub