We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Replace Footer In PPT File

How can I replace the footer of the attached file? The text is "##TitDoc". I'm using the code below but it isn't working.

pSlide.HeaderFooter.HeaderText = pSlide.HeaderFooter.HeaderText.Replace(item.Key.ToString(), item.Value.ToString())
pSlide.HeaderFooter.FooterText = pSlide.HeaderFooter.FooterText.Replace(item.Key.ToString(), item.Value.ToString())
pSlide.HeaderFooter.HeaderText = pSlide.HeaderFooter.HeaderText.Replace(item.Key.ToString(), item.Value.ToString())
pSlide.HeaderFooter.FooterText = pSlide.HeaderFooter.FooterText.Replace(item.Key.ToString(), item.Value.ToString())

Hi Rogger,


I have observed the code snippet shared by you and like to share that you are missing option for setting header footer visibility to true. Please visit this link for your further reference.

Many Thanks,

I've used the following code but it didn't work:

pSlide.HeaderFooter.FooterVisible = True
pSlide.HeaderFooter.HeaderVisible = True
pSlide.HeaderFooter.HeaderText = pSlide.HeaderFooter.HeaderText.Replace(item.Key.ToString(), item.Value.ToString())
pSlide.HeaderFooter.FooterText = pSlide.HeaderFooter.FooterText.Replace(item.Key.ToString(), item.Value.ToString())

Hi Rogger,


Please share the working sample code that you have used to reproduce the issue. I will investigate the issue on my end. Please try the latest version of Aspose.Slides for .NET 5.9.0.

Many Thanks,
ppt = New Presentation(pFileName)
 
For Each item As DictionaryEntry In htVarConf
    For Each pSlide As Slide In ppt.Slides
        For j As Integer = 0 To pSlide.Placeholders.Count - 1
              Dim th As TextHolder = CType(pSlide.Placeholders(j), TextHolder)
 
              th.Paragraphs(0).Portions(0).Text = th.Paragraphs(0).Portions(0).Text.Replace(item.Key.ToString(), item.Value.ToString())
        Next
        pSlide.HeaderFooter.FooterVisible = True
        pSlide.HeaderFooter.HeaderVisible = True
        pSlide.HeaderFooter.HeaderText = pSlide.HeaderFooter.HeaderText.Replace(item.Key.ToString(), item.Value.ToString())
        pSlide.HeaderFooter.FooterText = pSlide.HeaderFooter.FooterText.Replace(item.Key.ToString(), item.Value.ToString())
     Next
Next

Hi Rogger,


Please use the code snippet shared below for your kind reference. The following code works for me. Please share, if I may help you further in this regard.

Dim ppt As Presentation = New Presentation(“C:\Users\Mudassir\Downloads\Apresentation.ppt”)

’ For Each item As DictionaryEntry In htVarConf
For Each pSlide As Slide In ppt.Slides
For Each shp As Shape In pSlide.Shapes
If (shp.TextFrame.Text.Contains("##TitDoc")) Then
shp.TextFrame.Paragraphs(0).Text = “Text Changed”

End If
Next

Dim mas As Slide = ppt.GetSlideById(pSlide.MasterId)
For Each shp As Shape In mas.Shapes
If (shp.TextFrame.Text.Contains("##TitDoc")) Then
shp.TextFrame.Paragraphs(0).Text = “Text Changed”
End If

Next

pSlide.HeaderFooter.FooterVisible = True
pSlide.HeaderFooter.HeaderVisible = True

Next

ppt.Write(“C:\Users\Mudassir\Downloads\Apresentation2.ppt”)

Many Thanks,

It worked like a charm, thank you very much!