in regen notification, feature.getdefinition fails on config change

Okay, got a bit of code here that is firing when a part document is rebuilt.  The gist of what I am trying to do: I am getting information from a base flange about it's gauge table. 

In vb.net:

Function PartDoc_RegenNotify() As Integer
        Dim swFeat As IFeature
        Dim flatPatternFeature As IFeature
        Dim gageTablePath As String
        Dim BaseFlangeFeat As IBaseFlangeFeatureData
        Dim thickness As String
        Dim myDimension As Object

        Try
        flatPatternFeature = iPart.FeatureByName("Flat-Pattern1")

        If flatPatternFeature IsNot Nothing Then
            swFeat = iPart.FeatureByName("Base-Flange1")
                If swFeat IsNot Nothing Then
                    BaseFlangeFeat = swFeat.GetDefinition ---------this line bombs on config change
                    gageTablePath = BaseFlangeFeat.GaugeTablePath
                    thickness = BaseFlangeFeat.ThicknessTableName
                    myDimension = iPart.Parameter("kfactor@Sketch1")
                    myDimension.SystemValue = BaseFlangeFeat.KFactor / 1000
                    myDimension = iPart.Parameter("GaugeNumber@Sketch1")
                End If
            End If
        Catch ex As Exception

        End Try
    End Function

when I try to change configurations the line BaseFlangeFeat = swFeat.GetDefinition throws an exception

So, what is going on?  I *think* what is happening is SolidWorks is opening the underlying Excel table and taking write ownership of it, which makes the file 'write protected memory'.  Once this error occurs, solidworks starts doing all kinds of funny things.



So, how do I handle this?  I can't check to see if the gauge table is read only because I don't know what it is yet.  Any thoughts?



Jason

SolidworksApi macros