save as .xaml

Hello, i just started to use the SolidWorks API with VB.NET and i am currently doing a seminar work with it.

I am trying to start SolidWorks 2011 from an stand-alone wpf app, load a part (user specified) and save that part as .xaml. This i s what i have

        Dim swApp As SldWorks.SldWorks

        Dim swModel As ModelDoc2

        Dim swModDocExt As ModelDocExtension

        Dim bRet As Boolean

        Dim Errors, longstatus, longwarnings, Warnings As Long

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

        swModel = swApp.OpenDoc6(path+"\"+partName, SwConst.swDocumentTypes_e.swDocPART, 0, "", longstatus, longwarnings)

        swModel = swApp.ActivateDoc2(partName, False, Errors)

        swModDocExt = swModel.Extension

        bRet = swModDocExt.SaveAs(path+"\test.xaml", swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, Errors, Warnings)

It does not work, i get a xaml file with only this in it

      

      

On the other hand, when SolidWorks is already running, and i run the procedure, i get what i want. I assume it has to do something with activating the part, but can't really figure it out.

Thank you

SolidworksApi macros