Need help to solve that thing...
1. I take ByRef s As Shape in one of my functions. The shape contain some curves that need to be extracted one by one. So...
2. I extracting curves trough my another function, sience corel vba shape.Extract(OldReference) function is not properly documented and not working good, my function is:
Function ExtractSubpath(ByRef FromShape As Shape, ByVal Index As Long) As Shape' return extracted subpath as separate shape and delete it in original shape' and leave referencies for original shape Set ExtractSubpath = ActiveLayer.CreateCurve(FromShape.Curve.SubPaths(Index).GetCopy) With ExtractSubpath .OutLine.CopyAssign FromShape.OutLine .Fill.CopyAssign FromShape.Fill End With FromShape.Curve.SubPaths(Index).DeleteEnd Function
3. My ExtractSubpath function is working fine, but when last subpath is deleted - the shape s lost all referencies. My question is:
How to determine if shape s have some reference?
For example I've tried to check in such ways "If s.Curve.SubPaths>0 Then <do somthing>..." and "If Not s Is Nothing Then <do somthing>..." , but there an error... below is what hapens in watch before attemting to check s:
Watch : : s.Curve.SubPaths : <The referenced object no longer exists in this document.> : Integer : agWeb.BevelCurve
Thanks... Hope my english is good enough to understand me.
At the moment i've solved my trouble by checking, if extracted subpath was last one. Then assign for FromShape = Nothing. But, still remain courious about my question. And below is how my function is looking now:
Function ExtractSubpath(ByRef FromShape As Shape, ByVal Index As Long) As Shape' return extracted subpath as separate shape and delete it in original shape' and leave referencies for original shape Dim cnt As Long cnt = FromShape.Curve.SubPaths.count Set ExtractSubpath = ActiveLayer.CreateCurve(FromShape.Curve.SubPaths(Index).GetCopy) ExtractSubpath.OutLine.CopyAssign FromShape.OutLine ExtractSubpath.Fill.CopyAssign FromShape.Fill FromShape.Curve.SubPaths(Index).Delete If cnt = 1 Then Set FromShape = NothingEnd Function