1

Topic: It is not possible to interpose a picture in Excel through OLE

It is not possible  to interpose a picture in Excel through OLE. p_Disp = "Shapes" sz_Name = "AddPicture" Result of performance p_Disp-> Invoke - invalid args. Something not so with arguments but THAT I can not understand. I ask the help. Property_Put_Picture (IDispatch *p_Disp, OLECHAR FAR *sz_Name, const char *pc_Value) {__ int64 iL=strlen (pc_Value); OLECHAR *pwszValue=NULL; AnsiToUnicode (pc_Value, &pwszValue); ASSERT (p_Disp); hr = p_Disp-> GetIDsOfNames (IID_NULL, &sz_Name, 1, LOCALE_USER_DEFAULT, &dispid); {VARIANT vArgs [7+1] = {0}; DISPPARAMS dp = {NULL, NULL, 0, 0}; DISPID dispid_arg = DISPID_PROPERTYPUT; BSTR bstrTemp; VARIANT vResult; bstrTemp =:: SysAllocString (pwszValue); vArgs [0].vt = VT_BSTR; vArgs [0].bstrVal = bstrTemp; vArgs [1].vt = VT_BOOL; vArgs [1].boolVal = (short) FALSE; vArgs [2].vt = VT_BOOL; vArgs [2].boolVal = (short) FALSE; vArgs [3].vt = VT_R4; vArgs [3].fltVal = 0.0f; vArgs [4].vt vt = VT_R4; vArgs [4].fltVal = 0.0f; vArgs [5].vt = VT_R4; vArgs [5].fltVal = 100.0f; vArgs [6].vt = VT_R4; vArgs [6].fltVal = 100.0f; vArgs [7].vt = VT_VARIANT; dp.cArgs = 7+1; dp.rgvarg = vArgs;/* dp.cNamedArgs = 0; dp.rgdispidNamedArgs = &dispid_arg; */hr = p_Disp-> Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT,/*DISPATCH_PROPERTYPUT | */DISPATCH_METHOD, &dp, &vResult, NULL, NULL);:: SysFreeString (bstrTemp);} CoTaskMemFree (pwszValue);}

2

Re: It is not possible to interpose a picture in Excel through OLE

Hello, Sergey, you wrote: it is not possible  to interpose a picture in Excel through OLE. p_Disp = "Shapes" sz_Name = "AddPicture" Result of performance p_Disp-> Invoke - invalid args.> Something not so with arguments but THAT I can not understand. I ask the help. In IDispatch arguments are transferred upside-down.

3

Re: It is not possible to interpose a picture in Excel through OLE

Hello, bnk, you wrote: bnk> Hello, Sergey, you wrote:>> it is not possible  to interpose a picture in Excel through OLE.>> p_Disp = "Shapes">> sz_Name = "AddPicture">> Result of performance p_Disp-> Invoke - invalid args.> Something not so with arguments but THAT I can not understand.>> I Ask the help. bnk> in IDispatch arguments are transferred upside-down. Whether it is possible to show on this example? And, I was already tangled. And still: whether it is necessary to add 1 more argument?

4

Re: It is not possible to interpose a picture in Excel through OLE

Hello, Sergey, you wrote: bnk>> In IDispatch arguments are transferred upside-down. Whether It is possible to show on this example? It is possible. Try so for example (digits go upside-down, and 8th argument is not present - at AddPicture only 7 arguments): {VARIANT vArgs [7] = {0}; DISPPARAMS dp = {NULL, NULL, 0, 0}; BSTR bstrTemp; VARIANT vResult; bstrTemp =:: SysAllocString (pwszValue); vArgs [6].vt = VT_BSTR; vArgs [6].bstrVal = bstrTemp; vArgs [5].vt = VT_BOOL; vArgs [5].boolVal = (short) FALSE; vArgs [4].vt = VT_BOOL; vArgs [4].boolVal = (short) FALSE; vArgs [3].vt = VT_R4; vArgs [3].fltVal = 0.0f; vArgs [2].vt = VT_R4; vArgs [2].fltVal = 0.0f; vArgs [1].vt = VT_R4; vArgs [1].fltVal = 100.0f; vArgs [0].vt = VT_R4; vArgs [0].fltVal = 100.0f; dp.cArgs = 7; dp.rgvarg = vArgs; hr = p_Disp-> Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dp, &vResult, NULL, NULL);:: : SysFreeString (bstrTemp);}> And still: whether it is necessary to add 1 more argument? No, what for? Still, why you #import do not use? I.e. what for all this fresh-water sponge with IDispatch manually?

5

Re: It is not possible to interpose a picture in Excel through OLE

Hello, bnk, you wrote: bnk> Hello, Sergey, you wrote: bnk>>> In IDispatch arguments are transferred upside-down. Whether> It is possible to show on this example? bnk> it is possible. Try so for example (digits go upside-down, and 8th argument is not present - at AddPicture only 7 arguments):> And still: whether it is necessary to add 1 more argument? bnk> is not present, what for? Made, produces: 0x80020009 the Error. bnk> still why you #import do not use? I.e. what for all this fresh-water sponge with IDispatch manually? #import is that? Import of office libraries?

6

Re: It is not possible to interpose a picture in Excel through OLE

Hello, Sergey, you wrote:> Made, produces: 0x80020009 the Error something Here is difficult to tell. And what for an error? bnk>> still why you #import do not use? I.e. what for all this fresh-water sponge with IDispatch manually? >#import is that?> import of office libraries? Well, simply normally manually IDispatch it is not necessary  without special need on that. Besides intellisense will work normally. Your code with usage #import is reduced to: #import "progid:Excel. Sheet" auto_search auto_rename no_auto_exclude void AddPicture (Excel:: ShapesPtr disp, const char* pc_Value) {disp-> AddPicture (pc_Value, Office:: msoFalse, Office:: msoFalse, 0.0, 0.0, 100.0, 100.0);}

7

Re: It is not possible to interpose a picture in Excel through OLE

Hello, Sergey, you wrote: Made, produces: 0x80020009 the Error. Time the error did not change, most likely, the unassigned variable results in this message vResult. VARIANT' it is desirable to initialize always. Or to use _variant_t or CComVariant, which itself initialize. PS go not to set at all, as in your case with AddPicture.

8

Re: It is not possible to interpose a picture in Excel through OLE

Hello, Vi2, you wrote: Vi2> Hello, Sergey, you wrote:>> Made, produces: 0x80020009 the Error. Vi2> time the error did not change, most likely, the unassigned variable results in this message vResult. VARIANT' it is desirable to initialize always. Or to use _variant_t or CComVariant, which itself initialize. Vi2> PS Vi2> go not to set at all, as in your case with AddPicture. Can for this method there are any restrictions on the size, picture type? vResult - removed. The same error. In ExcepInfo.bstrDescription = 0x02968424 "Indicated value quits for tolerable limits." hr = p_Disp-> Invoke (dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dp, NULL //&vResult, &ExcepInfo, NULL);

9

Re: It is not possible to interpose a picture in Excel through OLE

Hello, Sergey, you wrote: Can for this method there are any restrictions on the size, picture type? vResult - removed. The same error. In ExcepInfo.bstrDescription = 0x02968424 "Indicated value quits for tolerable limits." Sub Makros1 () Dim v As Worksheet Set v = v. Shapes. AddPicture "picture.jpg", True, True, 0!, 0!, 100!, 100 v. Shapes. AddPicture "picture.jpg", True, False, 0!, 0!, 100!, 100 v. Shapes. AddPicture "picture.jpg", False, True, 0!, 0!, 100!, 100! V. Shapes. AddPicture "picture.jpg", False, False, 0!, 0!, 100!, 100! - here an error "1004 Indicated value quits for tolerable limits." End Sub Then values LinkToFile and SaveWithDocument cannot be equal False simultaneously. PS well." LinkToFile=False - To make the picture an independent copy of the file "and" SaveWithDocument=False - To store only the link information in the document "simultaneously are not fulfilled.

10

Re: It is not possible to interpose a picture in Excel through OLE

Vi2> Then values LinkToFile and SaveWithDocument cannot be equal False simultaneously. Vi2> PS Vi2> well. "LinkToFile=False - To make the picture an independent copy of the file" and "SaveWithDocument=False - To store only the link information in the document" simultaneously are not fulfilled. Thanks. Earned. It is necessary to understand with coordinates and scale