How to convert from ModelDoc2 to PartDoc in VBA

Hello all,

I've seen examples that convert a ModelDoc2 object to a PartDoc, but I can't seem to get it to work in VBA.  I get a Type Mismatch error.

Private Sub Test()

Dim swApp As SldWorks.SldWorks
Dim swModel1 As SldWorks.ModelDoc2
Dim swBody1 As SldWorks.Body2
Dim swPart1 As SldWorks.PartDoc

Dim vBodyResArr1 As Variant
Dim bret As Boolean
Dim i As Integer
Dim Save2Name As String

Set swApp = Application.SldWorks
Set swModel1 = swApp.ActiveDoc
Set swPart1 = swModel1  ' <---- Type Mismatch

swPart1.etc

swModel1.etc


End Sub

I'm guessing this is an example for VB 6.0.  For C#, CType seems to be right call.  For C++/COM, I've seen:

  CComQIPtr pPart = pModel;

and that works.

Any ideas for the VBA IDE?

Take care,

JC

SolidworksApi macros