Link to home
Start Free TrialLog in
Avatar of cossy74
cossy74

asked on

.Net, Word and formatting

Hi,

i need code to programmatically change the format type to be header 1 or header 2.
Can anyone help? I am using Word 2003
ASKER CERTIFIED SOLUTION
Avatar of Daniel Reynolds
Daniel Reynolds
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
(sheepishly) I'll take the points ;-)
Avatar of cossy74
cossy74

ASKER

xDJR1875: pretty close. The actual code is

                Word.Style GetStyle(string stylename)
            {                  
                  foreach(Word.Style style in oDoc.Styles)
                  {
                        if (style.NameLocal == stylename)
                        {
                              return style;
                        }
                  }
                  return GetStyle("Normal");
            }
            public void SetStyle(string stylename)
            {                  
                  object newstyle = GetStyle(stylename);
                  oWordApplic.Selection.set_Style(ref newstyle);
            }