app.CommandBars.GetImageMso Fail

Jul 9, 2013 at 1:25 PM
NetOffice.WordApi.Application app = ...;
Picture ipd = app.CommandBars.GetImageMso(imgMso, 16, 16) as Picture;
return IPictureDispConverter.ConvertPixelByPixel(ipd);
//FAIL


using WordApp = Microsoft.Office.Interop.Word.Application;

public static Bitmap GetBitmap(this Application app, string imgMso)
    {
        WordApp wordApp = app.UnderlyingObject as WordApp;
        Picture ipd = wordApp.CommandBars.GetImageMso(imgMso, 16, 16) as Picture;
        return IPictureDispConverter.ConvertPixelByPixel(ipd);
    }
//OK
Jul 12, 2013 at 1:49 AM
 Bitmap bitmap = null;
        object picProxy = Invoker.SingleMethodReturn(app.CommandBars, "GetImageMso", new object[] { imgMso, 16, 16 });
        if (picProxy != null) {
            bitmap = IPictureDispConverter.ConvertPixelByPixel(picProxy as Picture);
            Marshal.ReleaseComObject(picProxy);
        }
        return bitmap;