In other words do I need to release it with Marshal.ReleaseComObject()
?
I know Range
is and it needs to be released but I am not sure about the Formula
.
Asked
Active
Viewed 59 times
3

Mr1159pm
- 774
- 1
- 10
- 21
1 Answers
1
In the Excel object model Formula
is a string, not an object.
A simple test in Excel VBA:
Sub test()
Dim R As Variant
Set R = Range("A1")
Debug.Print TypeName(R)
Debug.Print TypeName(R.Formula)
End Sub
It prints:
Range
String

John Coleman
- 51,337
- 7
- 54
- 119
-
1thank you. I guess i was confused because in the addin express the returned value type is Object and in the VBA object browser the type is Variant. Is it possible it shows as string in the VBA but gets wrapped in an Object in the inter op? – Mr1159pm May 02 '16 at 01:23
-
@Mr1159pm I really don't know what sort of wrapping takes place when you use interop. If dot net strings are an object in a way that VBA strings are not then you are probably right that something like that goes on, but even if so I wouldn't think that the formula property is some sort of separate object that wouldn't be garbage-collected when the parent range object is released. – John Coleman May 02 '16 at 01:39