Reputation: 21
The code below gives me an error that says:
"Specified array was not of the expected type."
Sub SetSomeCellValues(ByVal vShape as Shape)
Dim srcStream as Integer() = {1,1,2,1,1,3}
Dim theFormulas as Array = {"0"}
vShape.SetFormulas(srcStream,theFormulas,visGetSetArgs.visSetBlastGuard)
End Sub
I have also tried setting theFormulas
to a String()
and an Object()
, but both result in the same error. This works in VBA if theFormulas
is set to a Variant. I have tried setting srcStream
to an array as well.
I found this link for a similar issue on stackoverflow, but the answer didn't help.
I would greatly appreciate any help from anyone who has ever gotten the .SetFormulas
, .GetFormulas
, or .GetResults
functions to work in .NET.
Upvotes: 0
Views: 153
Reputation: 21
The Microsoft documentation posted here is for VBA and does explicitly say to use a 2-byte integer, which is the Integer data type in VBA but is a Short or Int16 in .NET. For VB.NET use the following inputs:
Shape.SetFormulas(SID_SRCStream As Short(),formulaArray As Object(), Flags As visGetSetArg)
Upvotes: 2