/// <summary> /// 添加分页 /// </summary> public void AddPageing(Microsoft.Office.Interop.Word._Document odoc, object bookmark, ref Microsoft.Office.Interop.Word.Range wrdRng, int spaceafter) { object oPos; double dPos = oWord.InchesToPoints(7); do { wrdRng = oDoc.Bookmarks.get_Item(ref bookmark).Range; wrdRng.ParagraphFormat.SpaceAfter = spaceafter; wrdRng.InsertParagraphAfter(); oPos = wrdRng.get_Information (Microsoft.Office.Interop.Word.WdInformation.wdVerticalPositionRelativeToPage); }while (dPos >= Convert.ToDouble(oPos)); object oCollapseEnd = Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd; object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak; wrdRng.Collapse(ref oCollapseEnd); wrdRng.InsertBreak(ref oPageBreak); wrdRng.Collapse(ref oCollapseEnd); wrdRng.InsertParagraphAfter(); }
/// <summary> /// 记录书签位置 /// </summary> /// <param name="odoc"></param> /// <param name="bookmark"></param> /// <param name="oRng"></param> /// <param name="spaceafter"></param> public void BookmarkPos(Microsoft.Office.Interop.Word._Document odoc, object bookmark, ref Microsoft.Office.Interop.Word.Range wrdRng, int spaceafter) { wrdRng = odoc.Bookmarks.get_Item(ref bookmark).Range; wrdRng.ParagraphFormat.SpaceAfter = spaceafter; wrdRng.InsertParagraphAfter(); }