تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
(تم الحل) كيف احذف صفحة فارغة في ملف وورد؟
#3
وعليكم السلام ورحمة الله وبركاته

أضيفي أولا مكتبة Microsoft.Office.Interop.Word

Project >> Add Reference >> .NET >> Microsoft.Office.Interop.Word

ثم إستخدمي الأمر التالي :
كود :
Dim app As New Microsoft.Office.Interop.Word.Application
        app.Documents.Open("[color=#ff0000]C:\Users\OsamaGhareeb\Desktop\MyDoc.docx[/color]")
        Dim Doc = app.ActiveDocument
        Dim Pages = Doc.ComputeStatistics(Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages)
        Dim PEnd As Integer = 0
        For I = Pages To 1 Step -1
            Dim Range = Doc.Range.GoTo(What:=Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage, Which:=Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToAbsolute, Count:=I)
            Range.EndOf(Unit:=Microsoft.Office.Interop.Word.WdUnits.wdStory, Extend:=Microsoft.Office.Interop.Word.WdMovementType.wdExtend)
            If PEnd <> 0 Then Range.End = PEnd
            If Range.Text.Trim = "" Then
                If I = Pages Then Range.Start -= 1
                Range.Delete(Unit:=Microsoft.Office.Interop.Word.WdUnits.wdCharacter, Count:=1)
            End If
            If I = Pages Then Range.Start += 1
            PEnd = Range.Start
        Next
        Doc.Save()
        Doc.Close()

بالتوفيق
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
(تم الحل) كيف احذف صفحة فارغة في ملف وورد؟ - بواسطة Osama_Ghareeb - 03-12-12, 05:17 PM


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم