Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

Commented Unassigned: Exception thrown with Visio Page.GetFormulas [22311]

$
0
0
I am exploring using NetOffice.Visio for my project VisioAutomation: https://github.com/saveenr/VisioAutomation

Here's some code which works with Microsoft.Office.Interop.Visio

// using IVisio = Microsoft.Office.Interop.Visio;
var app = new IVisio.Application();
var doc = app.Documents.Add("");
var page = app.ActivePage;
var shape = page.DrawRectangle(0, 0, 2, 3);
shape.Text = "With Microsoft.Office.Interop.Visio";

var SID_SRCStream = new short[4];
SID_SRCStream[0] = (short)shape.ID16;
SID_SRCStream[1] = (short)IVisio.VisSectionIndices.visSectionObject;
SID_SRCStream[2] = (short)IVisio.VisRowIndices.visRowFill;
SID_SRCStream[3] = (short)IVisio.VisCellIndices.visFillForegnd;

System.Array a;
page.GetFormulasU(SID_SRCStream, out a);

But the same code throws an exception with NetOffice.Visio (for .NET 4.0)

// using IVisioNetOffice = NetOffice.VisioApi;
var app = new IVisioNetOffice.Application();
var doc = app.Documents.Add("");
var page = app.ActivePage;
var shape = page.DrawRectangle(0, 0, 2, 3);
shape.Text = "With NetOffice";

var SID_SRCStream = new short[4];
SID_SRCStream[0] = (short)shape.ID16;
SID_SRCStream[1] = (short)IVisioNetOffice.Enums.VisSectionIndices.visSectionObject;
SID_SRCStream[2] = (short)IVisioNetOffice.Enums.VisRowIndices.visRowFill;
SID_SRCStream[3] = (short)IVisioNetOffice.Enums.VisCellIndices.visFillForegnd;


object[] a;
page.GetFormulasU(SID_SRCStream, out a);

The exception occurs in GetFormulas the inner exception says "{"Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"}".

I suspect the problem is with the second parameter because setformulas seems to work with the same SID_SRCStream.

Any ideas what is wrong in my code?


Comments: I can reproduce the issue right now. In order to continute to work with NetOffice asap i create a bypass for you as linq extension(see attachment) This should work in all Visio versions(*1) (11 to 16) - but only true tested in 16-2016 (sry i'm not at home) I want create a C++ COM server now with the same method signature as IVPage::GetFormulas and IDispatch support to analyze the problem with a C# dumy client. I'll be back as fast i can. If you have problems with the given bypass or other/new problems - please let me know. *Sebastian (*1) = The bypass use the early bind implementation behind in a lightweight way. This works versionless and fine when the interface id and the method dispid/method signature never has been changed. IVPage interface id and GetFormula method never has been changed.

Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>