Click here to Skip to main content
15,913,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i need to remove page footer on the last page of document.


VB
Dim sfd As New SaveFileDialog
       With sfd
           .AddExtension = True
           .DefaultExt = ".doc"
           .Filter = "Word Document Files (*.doc)|*.doc"
           .FilterIndex = 1
           .InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
           .Title = "Select The Location To Save This Word File"
           .ValidateNames = True
       End With

       If sfd.ShowDialog() = DialogResult.OK Then
           Try
               Dim svLocation As String = sfd.FileName

               rtbcomplete.SaveFile(svLocation)

               'opening the doc file to add header and footer

               Dim objApp As Word.Application
               Dim objDoc As Word.Document
               objApp = New Word.Application()
               objDoc = objApp.Documents.Open(svLocation)

               For Each section As Word.Section In objDoc.Sections
                   Dim footerRange As Word.Range = section.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range
                   footerRange.InlineShapes.AddPicture("E:\Storage\Signed\f.jpg")
                   Dim headerRange As Word.Range = section.Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range
                   headerRange.InlineShapes.AddPicture("E:\Storage\Signed\h.jpg")
               Next


               objDoc.Save()
               objDoc.Close()

           Catch ex As Exception
               MessageBox.Show(ex.Message)
           End Try
       End If
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900