This is regular iLogic (VB.net), not API (VBA), but its easily convertible by adding a 'Set', and a 'Call' or few in there. After finding the Sketch, it sets it as Shared, so that it can be used by multiple ExtrudeFeatures if needed. Then it basically just goes another step deeper in the Profile to its ProfileFaths, checks whether they are 'Closed' or not, then sets its '.AddsMaterial' property.
I think you can play around with this idea to achieve your goal.
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oSketch As PlanarSketch = oCompDef.Sketches.Item(1)
oSketch.Shared = True
Dim oProfiles As Profiles = oSketch.Profiles
For Each oProfile As Profile In oPrfiles
If oProfile.Count > 1 Then
For i = 1 To oProfile.Count
If oProfile.Item(i).Closed = True Then
oProfile.Item(i).AddsMaterial = True
End If
Next
End If
oProfiles.AddForSolid ' You can modify the Optional Parameters of this if needed.
Dim oExtFeats As ExtrudeFeatures = oCompDef.Features.ExtrudeFeatures
Dim oExtrudeDef As ExtrudeDefinition
oExtrudeDef = oExtFeats.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kNewBodyOperation)
oExtrudeDef.SetDistanceExtent(10, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
Dim oExtrude As ExtrudeFeature
oExtrude = oExtFeats.Add(oExtrudeDef)
Next
Check out the following link for additional info.
http://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-5A9FA7CB-1EB9-4849-BB9D-11AD01F3DBF6
And this example
http://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-E9592972-C31C-4800-9699-C069E5C92BC3
Wesley Crihfield

(Not an Autodesk Employee)