2017-09-07 47 views
0

下面的代码给了我一个错误,指出:如何使用Shape.SetFormulas在VB.NET在Visio

“指定数组是期望类型的内容。”

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 

我自己也尝试设置theFormulasString()Object(),但两者产生相同的错误。如果theFormulas设置为Variant,则在VBA中可用。我也尝试将srcStream设置为一个数组。

我找到了this link在stackoverflow上的类似问题,但答案没有帮助。

我非常感谢任何人的帮助,这些人曾经使用过.NET中的.SetFormulas,.GetFormulas.GetResults函数。

+1

的Vb.Net短(System.Int16)数据类型是VBA的整数数据类型的等同物。 – TnTinMn

回答

2

微软公布的文档here用于VBA,并且明确表示使用2字节整数,这是VBA中的Integer数据类型,但是是.NET中的Short或Int16。对于VB.NET使用以下输入:

Shape.SetFormulas(SID_SRCStream As Short(),formulaArray As Object(), Flags As visGetSetArg)