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

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

大多数部分的代码都会运行,但是,即使正确调整了监视窗口中的对象,“讲义”和“注释主 Headers ”也不会更改文本 . 当单步执行代码并在结尾处暂停时,我从PowerPoint功能区打开“插入页眉/页脚”,并找到正确调整的对话框字段,但Notes仍然具有[DOCID#]代码 .

我还注意到,从客户提供的模板,演示文稿可以有.HasTitleMaster返回True,但在尝试访问.Footer.Text时我收到错误(无效对象...)

有任何想法吗?