المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Not able to assign the picture to toolbar item.



C# Programming
03-26-2010, 07:21 PM
Hi,

I have created toolbar for Excel. To one of the toolbar item i am trying associate the image. But it is failing.

stdole.IPictureDisp p = AxHost.GetIPictureDispFromPicture(image) as stdole.IPictureDisp;
commandBarButton.Picture = p;

When I am trying to assigning to command bar picture it is throwing following error.

Error HRESULT E_FAIL has been returned from a call to a COM component. (source: Office)
Exception info:System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at Microsoft.Office.Core._CommandBarButton.set_Picture(IPictureDisp ppdispPicture)

Based on some events this tool bar image is changing.

I am not sure why it failing.But same thing is working for menu bar item.

Please help.