Getting offset planes..

Trying to get no. of planes automatically.. Getting error as Object variable not set in bolded line.. Any help ?

Dim swApp As Object  

Dim Part, Model As Object 

Dim planeName, newPlaneName As String

Dim planeFeature As Object

Dim i, planeCount As Integer

Set swApp = CreateObject("SldWorks.Application")

Set Model = swApp.ActiveDoc

If Model Is Nothing Then

Exit Sub

End If

newPlaneName = "Plane1"

planeCount = 0

For i = 1 To 5

Model.ClearSelection

Model.SelectByID newPlaneName, "PLANE", 0, 0, 0

Model.CreatePlaneAtOffset 0.1, 0

planeCount = planeCount + 1

planeName = "Plane" & planeCount

newPlaneName = "MyPlane" & i

Set planeFeature = Model.FeatureByName(planeName)

planeFeature.Name = (newPlaneName)

Model.EditRebuild

Next

End Sub

SolidworksApi macros