Word 常用范例

插入空白段落:

Object end = "//endofdoc"; Object r = doc.Bookmarks.get_Item(ref end).Range; Paragraph p = document.Paragraphs.Add(ref r); p.Range.Text = ""; p.Range.Bold = 0; p.OutlineLevel = WdOutlineLevel.wdOutlineLevelBodyText; p.Range.InsertParagraphAfter();

添加下划线:

public void DrawUnderLine(Paragraph p, string s) { Object b= p.Range.End - 1; Object none= System.Type.Missing; Object u= Word.WdUnits.wdStory; app.Selection.EndKey(ref u, ref none); app.Selection.TypeText(s); Object e = doc.Content.End - 1; Range r= document.Range(ref b, ref e); r.Font.Underline = WdUnderline.wdUnderlineSingle; }

首行缩进:

p.Format.CharacterUnitFirstLineIndent = 2;

剪切与粘贴:

int b = app.Selection.Range.End; int e = app.Selection.End; Word.Range r = document.Range(ref b, ref e); r.Select(); app.Selection.Cut(); t.Cell(1, 1).Width = 200; t.Cell(1, 1).Height = 300; t.Cell(1, 1).Select(); app.Selection.PasteAndFormat(WdRecoveryType.wdPasteDefault);

单元格垂直居中:

t.Range.Cells.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter;

分页:

object u = Word.WdUnits.wdStory; app.Selection.EndKey(ref u, ref none); Object p = (int)Word.WdBreakType.wdSectionBreakNextPage; app.Selection.InsertBreak(ref p);

设置页面方向:

app.Selection.PageSetup.Orientation = wdOrientation; doc.PageSetup.Orientation = wdOrientation;

你可能感兴趣的:(Word 常用范例)