Get thickness of sheetmetal part without selecting any face

I am working on a program to save DXF file into separate thickness wise folders(if it is there else create new folder). To get started i first need to get the thickness of part, and for that i found a program from one of forums, but when i select any face other than the base flange face, it gives me debug error, I am thinking if i can get the thickness without selecting any face. The program is:

<p>Option Explicit</p><p></p><p></p><p>Sub main()</p><p></p><p></p><p>    Dim swApp                   As SldWorks.SldWorks</p><p>    Dim swModel                 As SldWorks.ModelDoc2</p><p>    Dim vConfNameArr            As Variant</p><p>    Dim sConfigName             As String</p><p>    Dim nStart                  As Single</p><p>    Dim i                       As Long</p><p>    Dim bShowConfig             As Boolean</p><p>    Dim bRebuild                As Boolean</p><p>    Dim bRet                    As Boolean</p><p>   </p><p>    Dim swsel As SldWorks.SelectionMgr</p><p>    Dim swface As SldWorks.Face2</p><p>    Dim swfeature As SldWorks.Feature</p><p>    Dim swfeaturedata As Object</p><p>    Dim Thickness As String</p><p>    </p><p>   </p><p></p><p></p><p>    Set swApp = Application.SldWorks</p><p>    Set swModel = swApp.ActiveDoc</p><p>    </p><p>    Set swsel = swModel.SelectionManager</p><p>    Set swface = swsel.GetSelectedObject(1)</p><p>    Set swfeature = swface.GetFeature</p><p>    Set swfeaturedata = swfeature.GetDefinition</p><p></p><p></p><p>    Thickness = swfeaturedata.Thickness</p><p></p><p></p><p>    swApp.SendMsgToUser "Sheet Thickness" & " " & Thickness * 1000 & "mm"</p><p></p><p></p><p>      </p><p></p><p></p><p>    vConfNameArr = swModel.GetConfigurationNames</p><p></p><p></p><p>    For i = 1 To UBound(vConfNameArr)</p><p></p><p></p><p>        sConfigName = vConfNameArr(i)</p><p></p><p></p><p>        </p><p>bShowConfig = swModel.ShowConfiguration2(sConfigName)</p><p></p><p></p><p>bRebuild = swModel.ForceRebuild3(False)</p><p></p><p></p><p>Dim FilePath As String</p><p>Dim PathSize As Long</p><p>Dim PathNoExtension As String</p><p>Dim NewFilePath As String</p><p></p><p></p><p>FilePath = swModel.GetPathName</p><p>PathSize = Strings.Len(FilePath)</p><p>PathNoExtension = Strings.Left(FilePath, PathSize - 6)</p><p></p><p></p><p></p><p></p><p>NewFilePath = PathNoExtension + sConfigName & ".DXF"</p><p></p><p></p><p>'Export Flat Pattern</p><p>bRet = swModel.ExportFlatPatternView(NewFilePath, swExportFlatPatternOption_None)</p><p></p><p></p><p>Next i</p><p></p><p></p><p>End Sub</p>

I succeeded in getting sheet thickness, but i want it without selecting any face.

Thanks

SolidworksApi macros