Hi have this code that runs well for me. It's part of my WordWrapper where Sel is defined as the Selection object.
I tried to save Sel.Font to a var f
variable, and reset Sel.Font = f
before exit, but that does not work. "Value out of range".
/// <summary>
/// Write String Bold/Underline/Size 14.
/// </summary>
/// <param name="s"></param>
public void Header(string s)
{
var b = Sel.Font.Bold;
var u = Sel.Font.Underline;
var size = Sel.Font.Size;
Sel.Font.Bold = (int) Word.WdConstants.wdToggle;
Sel.Font.Underline = Word.WdUnderline.wdUnderlineSingle;
Sel.Font.Size = 14;
Sel.TypeText(s);
Sel.Font.Bold = b;
Sel.Font.Underline = u;
Sel.Font.Size = size;
}