tr7
Tue Jun 17 16:39:00 PDT 2008
thanks very much everyone. The error was that I forgot that -1 is true and 0
is false. Thanks again. I really appreciate it.
"Jay Freedman" wrote:
> tr7 wrote:
> > Hi,
> > I have a method in C# which is trying to change the font from
> > unformatted to either italics or underline in a TA field code.
> >
> > I'm doing:
> >
> > Application.Selection.Range.Font.Italic == 1;
> >
> > and it keeps reverting back to -1 as the value for italic so the font
> > remains unformatted. Does anyone know how I can apply a format to
> > selected text in a TA field code and have it stick? Thanks very much.
>
> If your code is exactly as shown, the == operator is the problem. It's the
> C# operator for comparison for equality. That means you aren't assigning a
> value to anything. Use only a single = sign.
>
> A second "problem" is that the value of the constant True in VB/VBA is -1
> and not 1.
>
> A possible third problem is that the field code must be displayed and the
> desired text inside it must be selected in order for this statement to have
> any effect. Can you verify that that's the case at run time?
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ:
http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.
>
>
>