word文档工程变量的
//合并单元格
table.Cell(2, 2).Merge(table.Cell(2, 3));
//单元格分离
object Rownum = 2;
object Columnnum = 2;
table.Cell(2, 2).Split(ref Rownum, ref Columnnum);
//单元格对齐方式
WApp.Selection.Cells.VerticalAlignment =Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
//插入表行
table.Rows.Add(ref missing);
//分页 object ib = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
WApp.Selection.InsertBreak(ref ib);
//换行
WApp.Selection.TypeParagraph();
二、word文档设置
WApp.ActiveDocument.PageSetup.LineNumbering.Active =0;//行编号
WApp.ActiveDocument.PageSetup.Orientation =Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait;//页面方向
WApp.ActiveDocument.PageSetup.TopMargin =WApp.CentimetersToPoints(float.Parse("2.54"));//上页边距
WApp.ActiveDocument.PageSetup.BottomMargin = WApp.CentimetersToPoints(float.Parse("2.54"));//下页边距
WApp.ActiveDocument.PageSetup.LeftMargin = WApp.CentimetersToPoints(float.Parse("3.17"));//左页边距
WApp.ActiveDocument.PageSetup.RightMargin = WApp.CentimetersToPoints(float.Parse("3.17"));//右页边距
WApp.ActiveDocument.PageSetup.Gutter = WApp.CentimetersToPoints(float.Parse("0"));//装订线位置
WApp.ActiveDocument.PageSetup.HeaderDistance = WApp.CentimetersToPoints(float.Parse("1.5"));//页眉
WApp.ActiveDocument.PageSetup.FooterDistance = WApp.CentimetersToPoints(float.Parse("1.75"));//页脚
WApp.ActiveDocument.PageSetup.PageWidth = WApp.CentimetersToPoints(float.Parse("21"));//纸张宽度
WApp.ActiveDocument.PageSetup.PageHeight = WApp.CentimetersToPoints(float.Parse("29.7"));//纸张高度
WApp.ActiveDocument.PageSetup.FirstPageTray = Microsoft.Office.Interop.Word.WdPaperTray.wdPrinterDefaultBin;//纸张来源
WApp.ActiveDocument.PageSetup.OtherPagesTray = Microsoft.Office.Interop.Word.WdPaperTray.wdPrinterDefaultBin;//纸张来源
WApp.ActiveDocument.PageSetup.SectionStart = Microsoft.Office.Interop.Word.WdSectionStart.wdSectionNewPage;//节的起始位置:新建页
WApp.ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter = 0;//页眉页脚-奇偶页不同
WApp.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = 0;//页眉页脚-首页不同
WApp.ActiveDocument.PageSetup.VerticalAlignment = Microsoft.Office.Interop.Word.WdVerticalAlignment.wdAlignVerticalTop;//页面垂直对齐方式
WApp.ActiveDocument.PageSetup.SuppressEndnotes =0;//不隐藏尾注
WApp.ActiveDocument.PageSetup.MirrorMargins = 0;//不设置首页的内外边距
WApp.ActiveDocument.PageSetup.TwoPagesOnOne = false;//不双面打印
WApp.ActiveDocument.PageSetup.BookFoldPrinting =false;//不设置手动双面正面打印
WApp.ActiveDocument.PageSetup.BookFoldRevPrinting =false;//不设置手动双面背面打印
WApp.ActiveDocument.PageSetup.BookFoldPrintingSheets = 1;//打印默认份数
WApp.ActiveDocument.PageSetup.GutterPos = Microsoft.Office.Interop.Word.WdGutterStyle.wdGutterPosLeft;//装订线位于左侧
WApp.ActiveDocument.PageSetup.LinesPage = 40;//默认页行数量
WApp.ActiveDocument.PageSetup.LayoutMode = Microsoft.Office.Interop.Word.WdLayoutMode.wdLayoutModeLineGrid;//版式模式为“只指定行网格”
三、光标移动
//移动光标
//光标下移3行 上移3行
object unit = Microsoft.Office.Interop.Word.WdUnits.wdLine;
object count = 3;
WApp.Selection.MoveEnd(ref unit,ref count);
WApp.Selection.MoveUp(ref unit, ref count, ref missing);
//Microsoft.Office.Interop.Word.WdUnits说明
//wdCell A cell.
//wdCharacter A character.
//wdCharacterFormatting Character formatting.
//wdColumn &n