Area of a SolidWorks Sketch in VBA

Hello everyone, in the context of a project that is a little long I get stuck on a simple point: I have to determine (in a macro) the area of a sketch (in the Double form) to then copy it into an Exel file (that's good). The macro-free equivalent is:

  1. select the sketch (named "Step5")
  2. Surface Ownership
  3. extract the area (or the area, it comes down to the same thing in this case) and associate it with a variable of type Double

I've already tried this piece of code but the "extract area" phase, as you can imagine, doesn't work (the rest does).

 

Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub copySurface()

Dim surfaceSelection As Double

'*************************************
Enables the open document in SolidWorks
'*************************************

Set swApp = _
Application.SldWorks
Set Part = swApp.ActiveDoc

'*************************************
'Extract the area of the sketch
'*************************************

Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("step5", "FACE", 0, 0, 0, False, 0, Nothing, 0)

Dim swMesure As Measure
Set swMesure = Part.Extension.CreateMeasure

monAire = swMesure.Area

'*************************************
'Selects the current open Exel file
'*************************************


Set swApp = CreateObject("SldWorks.Application")
Set xlApp = GetObject(, "Excel.Application")
Set Part = swApp.ActiveDoc
Set Xlsh = xlApp.Application.ActiveSheet

'*************************************
Implementing the value in the Excel table
'*************************************

Xlsh.Cells(2, 2) = monAire

End Sub

 

There you go, if some have ideas, thank you in advance!

It's a good problem, solve.