Beispiel #1
0
        public void deletePage(object page)
        {
            object oMissing = System.Reflection.Missing.Value;
            int    pages    = wordDoc.ComputeStatistics(Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages, ref oMissing);
            object objWhat  = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
            object objWhich = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToAbsolute;

            Microsoft.Office.Interop.Word.Range range1 = wordDoc.GoTo(ref objWhat, ref objWhich, ref page, ref oMissing);
            Microsoft.Office.Interop.Word.Range range2 = range1.GoToNext(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage);
            object bjStart = range1.Start;
            object objEnd  = range2.Start;
            object Unit    = (int)Microsoft.Office.Interop.Word.WdUnits.wdCharacter;
            object Count   = 1;

            wordDoc.Range(ref bjStart, ref objEnd).Delete(ref Unit, ref Count);

            object what  = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToLine;
            object which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToFirst;
            object count = 1;

            wordApp.Selection.GoTo(ref what, ref which, ref count, ref oMissing).Delete();
        }