5
$\begingroup$

I'm using the NETLink to work with Excel object, there be differences to write code according to the NETLink user manual in Mathematica from C#, but it's hard to do more in fact.

I wanted to put a picture in Excel ActiveSheet, the MSDN gvies notation like this in C#:

public Microsoft.Office.Interop.Excel.Picture Insert (string Filename, object Converter);

first time I trans it as

activesheet@Cells[20, 1]@Select[]
activesheet@Pictures@Insert["E:\\birds.png"]

error ocurred. ... at last, the code was changed to

activesheet@Cells[20, 1]@Select[]    
activesheet@Pictures[]@Insert["E:\\birds.png"]

and it worked. I donot know why paired brackets is necessary for the Pictures? so I hope there be particular Classes browser for NETLink more than the NETTypeInfo function to help understand these objects exactly. If there be Classes browser designed for Assembly when using NETLink would be better?

enter image description here

$\endgroup$

1 Answer 1

4
$\begingroup$

The crux of the issue is that the symbol WorksheetClass.Pictures is a method, not a property. When using NETLink, methods must always be followed by an argument list, even when no arguments are being specified.

We can distinguish between methods and properties by inspecting the NETTypeInfo:

NETTypeInfo["Microsoft.Office.Interop.Excel.WorksheetClass"]

NETTypeInfo screenshot

Here we see that Pictures is a method that takes a single optional index argument.

$\endgroup$
1
  • $\begingroup$ Yes, thanks! I hope there be GUI tool in NETLink package to help looking up like object browser in VisualStudio IDE $\endgroup$
    – Jerry
    Nov 20, 2018 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.