--- In [email protected], "Sheri" <sheri...@...> wrote: > > --- In [email protected], "entropyreduction" > <alancampbelllists+yahoo@> wrote: > > > > > > > > --- In [email protected], "Sheri" <sherip99@> wrote: > > > > > Here it states that to use a default value, the optional variant value > > > must test as "missing". Possibly the result of initializing the empty > > > variant. > > > > > <http://msdn.microsoft.com/en-us/library/aa164532%28office.10%29.aspx> > > > > It also says "Note that any parameter that is marked as > > optional--meaning you can omit the value and Word will pick a > > reasonable default value or ignore that option--is marshalled as > > a pointer to a VARIANT in Word (Excel doesn't typically use a > > pointer to a VARIANT for optional parameters so you don't have > > this by ref issue for most of Excel)." > > > > And sure enough if you look at signature for CheckSpelling, lots > > of VARIANTs, no VARIANT*s (VARIANT* is a sign I should use ByRef > > -- in fact I probably change output from description methods so > > that's what you see). > OK, try this then. Create the VARIANT with VT_ERROR etc. Send a pointer to > this VARIANT using VT_VARIANT|VT_BYREF. Its the only way to ensure that > another process is going to see this VARIANT exactly the way you make it.
In general, one send a server what it expects: if type info says it wants a VT_VARIANT, you give it a VT_VARIANT. If it says it wants a VT_VARIANT*, you give it a VT_VARIANT|VT_BYREF. CheckSpelling says it wants a VT_VARIANT, so that's what it gets. However, next week I can override code that sends optionals and make it then them as VT_VARIANT|VT_BYREF. Why not? And no, per a parallel post, once an optional parameter is set up the code that turns parameters into VARIANTs returns to caller. So nothing more can happen to that particular VARIANT.
