using System;
using System.Collections.Generic;
using System.Text;
namespace ControlWord
{
public class CCWordApp
{
private Word.ApplicationClass oWordApplic;// a reference to Word application
private Word.Document oDoc;// a reference to the document
object Unit = (int)Word.WdUnits.wdCharacter;
object Count = 1;
oWordApplic.Selection.WholeStory();
oWordApplic.Selection.Delete(ref Unit, ref Count);
}
public void InsertText(string strText)
{
oWordApplic.Selection.TypeText(strText);
}
public void InsertLineBreak()
{
oWordApplic.Selection.TypeParagraph();
}
public void InsertLineBreak(int nline)
{
for (int i = 0; i < nline; i++)
oWordApplic.Selection.TypeParagraph();
}
public void SetAlignment(string strType)
{
switch (strType)
{
case "Center":
oWordApplic.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
break;
case "Left":
oWordApplic.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft;
break;
case "Right":
oWordApplic.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
break;
case "Justify":
oWordApplic.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphJustify;
break;
}
}
public void SetFont(string strType)
{
switch (strType)
{
case "Bold":
oWordApplic.Selection.Font.Bold = 1;
break;
case "Italic":
oWordApplic.Selection.Font.Italic = 1;
break;
case "Underlined":
oWordApplic.Selection.Font.Subscript = 0;
break;
}