03-12-12, 05:17 PM
وعليكم السلام ورحمة الله وبركاته
أضيفي أولا مكتبة Microsoft.Office.Interop.Word
Project >> Add Reference >> .NET >> Microsoft.Office.Interop.Word
ثم إستخدمي الأمر التالي :
بالتوفيق
أضيفي أولا مكتبة 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()بالتوفيق
