VBA Powerpoint 2010replace页眉和页脚中的文本

挑战PowerPoint模板的页眉/页脚中的[DOCID#]代码。 我注意到在PowerPoint对象浏览器中,在演示文稿(SlideMaster,NotesMaster,HandoutMaster,TitleMaster,然后是每个单独的幻灯片)的许多部分都可以find页眉和页脚。 我正在运行XL中的代码,并且引用了PowerPoint库的Dim'ed。

Set ppPres = ppApp.Presentations.Open(sTemplate) Set ppMaster = ppPres.SlideMaster With ppMaster.HeadersFooters .Footer.Text = Replace(.Footer.Text, "[DOCID#]", sDocID) End With If ppPres.HasNotesMaster Then Set ppMaster = ppPres.NotesMaster With ppMaster.HeadersFooters .Footer.Text = Replace(.Footer.Text, "[DOCID#]", sDocID) .Header.Text = Replace(.Header.Text, "[DOCID#]", sDocID) End With End If If ppPres.HasHandoutMaster Then Set ppMaster = ppPres.HandoutMaster With ppMaster.HeadersFooters .Footer.Text = Replace(.Footer.Text, "[DOCID#]", sDocID) .Header.Text = Replace(.Header.Text, "[DOCID#]", sDocID) End With End If If ppPres.HasTitleMaster Then Set ppMaster = ppPres.TitleMaster With ppMaster.HeadersFooters .Footer.Text = Replace(.Footer.Text, "[DOCID#]", sDocID) End With End If For Each ppSlide In ppPres.Slides With ppSlide.HeadersFooters .Footer.Text = Replace(.Footer.Text, "[DOCID#]", sDocID) End With Next ppSlide 

尽pipe监视窗口中的对象已被正确调整,但大部分代码仍在运行,但Handout和Notes主标题不会更改文本。 当逐步完成代码并在最后暂停时,我从PowerPointfunction区中打开“插入页眉/页脚”,并find正确调整的对话框字段,但Notes仍然有[DOCID#]代码。

我也注意到,从客户提供的模板,演示文稿可以有.HasTitleMaster返回True,但是当试图访问.Footer.Text时,我得到一个错误(无效的对象…)

有任何想法吗?