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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(sheepishly) I'll take the points ;-)
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);
}
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_
}