.net code opens a new instance of SolidWorks

Hello Guys,

I'm working a little .net kode which first of all should just do a force rebuild of an open part in SolidWorks 2014:

-------------------code-------------------

Imports SolidWorks.Interop.sldworks

Imports SolidWorks.Interop.swcommands

Imports SolidWorks.Interop.swconst

Imports System.Runtime.InteropServices

Module ForceRebuildSld

    Dim swModel As ModelDoc2

    Dim swApp As SldWorks.SldWorks

    Dim TopOnly As Boolean

    Sub StartRebuild()

        swApp = GetObject("", "SldWorks.Application")

        swModel = swApp.ActiveDoc

        'Forces a rebuild of all of the features in the model whether they need a rebuild.

        If swModel Is Nothing Then

            MsgBox("There was nothing in swModel:",, "Crowdforce")

        Else

            If swModel.ForceRebuild3(True) Then

                MsgBox("Forced rebuild successful",, "Crowdforce")

            Else

                MsgBox("This model has rebuild errors",, "Crowdforce")

            End If

            'save/close stuff

            'swModel.Save()

        End If

    End Sub

End Module

-----------------code end-----------------

It opens a second solidworks and therefore the swModel doesn't get any data, and it fails because there is nothing to rebuild.

I'm very new to .net, any help would be greatly appreciated.

Thanks in advance

SolidworksApi macros