从Word VBA编辑PowerPoint演示文稿页脚

从Word VBA编辑PowerPoint演示文稿页脚,vba,ms-word,powerpoint,Vba,Ms Word,Powerpoint,我有Word中的代码,可以复制文件夹,将文件夹粘贴到类似区域,并将文件重命名为当前周数 文件夹中的文件中有一个PowerPoint演示文稿。演示文稿有一个带有文本的页脚,我希望在Word代码中更新该文本。我试过很多不同的方法 这是我当前的代码: Dim FSO As Object Dim FromPath As String Dim ToPath As String Message = Format(Date, "ww", vbSunday) 'if message < 10 then

我有Word中的代码,可以复制文件夹,将文件夹粘贴到类似区域,并将文件重命名为当前周数

文件夹中的文件中有一个PowerPoint演示文稿。演示文稿有一个带有文本的页脚,我希望在Word代码中更新该文本。我试过很多不同的方法

这是我当前的代码:

Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Message = Format(Date, "ww", vbSunday)

'if message < 10 then it will be KW0 + WEEK NUMBER. IF IT IS BIGGER THAN TEN, IT WILL BE KW + NUMBER.

If Message < 10 Then
    FromPath = "directory here"
    ToPath = "directory here"
End If

If Message >= 10 Then
    FromPath = "directory here"
    ToPath = "directory here"
End If

If Right(FromPath, 1) = "\" Then
    FromPath = Left(FromPath, Len(FromPath) - 1)
End If

If Right(ToPath, 1) = "\" Then
    ToPath = Left(ToPath, Len(ToPath) - 1)
End If

Set FSO = CreateObject("scripting.filesystemobject")

If FSO.FolderExists(FromPath) = False Then
    MsgBox FromPath & " doesn't exist. Please speak to me."
    Exit Sub
End If

FSO.CopyFolder Source:=FromPath, Destination:=ToPath

If Message < 10 Then
    Name "directory here" _
    As "directory here"

    Name "directory here" _
    As "directory here"
End If

If Message >= 10 Then
    Name "directory here" _
    As "directory here"

    Name "directory here" _
    As "directory here"
End If
Dim FSO作为对象
将FromPath设置为字符串
作为字符串的Dim-ToPath
消息=格式(日期,“ww”,vbSunday)
'如果消息<10,则为KW0+周数。如果大于10,则为KW+数字。
如果消息<10,则
FromPath=“此处的目录”
ToPath=“此处的目录”
如果结束
如果消息>=10,则
FromPath=“此处的目录”
ToPath=“此处的目录”
如果结束
如果Right(FromPath,1)=“\”则
FromPath=Left(FromPath,Len(FromPath)-1)
如果结束
如果Right(ToPath,1)=“\”则
ToPath=Left(ToPath,Len(ToPath)-1)
如果结束
设置FSO=CreateObject(“scripting.filesystemobject”)
如果FSO.FolderExists(FromPath)=False,则
MsgBox FromPath&“不存在。请与我联系。”
出口接头
如果结束
FSO.CopyFolder源:=FromPath,目标:=ToPath
如果消息<10,则
名称“此处目录”_
作为“此处的目录”
名称“此处目录”_
作为“此处的目录”
如果结束
如果消息>=10,则
名称“此处目录”_
作为“此处的目录”
名称“此处目录”_
作为“此处的目录”
如果结束
以上工作

转到演示文稿的开头如下:(注意:演示文稿已打开,但我无法在VBA代码中编辑页脚。)

Dim opptap作为PowerPoint.Application
将oPPTFile设置为PowerPoint。演示文稿
将oPPTSlide变暗为PowerPoint。幻灯片
Set opptap=CreateObject(“PowerPoint.Application”)
opptap.Visible=msoTrue
如果消息<10,则
设置oPPTFile=opptap.Presentations.Open(文件名:=“此处目录”)
如果结束
如果消息>=10,则
设置oPPTFile=opptap.Presentations.Open(文件名:=“此处目录”)
如果结束
ActivePresentation.Slides(1).HeadersFooters.Footer.Text=“火山咖啡”
MsgBox“下周的包现在已经生成!”
端接头

要更改
HeaderFooter
对象中的设置,必须确保该对象“可见”,否则该对象不存在。比如说

With oPPTFile.Slides(1).HeadersFooters.Footer
   .Visible = True
   .Text = "Volcano Coffee"
End With

要更改
HeaderFooter
对象中的设置,必须确保该对象“可见”,否则该对象不存在。比如说

With oPPTFile.Slides(1).HeadersFooters.Footer
   .Visible = True
   .Text = "Volcano Coffee"
End With

指定Footer.Text的代码行在PowerPoint VBA中有效吗?而且,看看你发布的代码,当你已经实例化了
oPPTFile
,不要使用
ActivePresentation
-使用它。@Cindymister,我不能100%确定footer.text是否在VBA中工作。我收到一个有关ActiveX的错误代码,或者收到一条错误消息,指出“HeaderFooter”是未知成员。指定Footer.Text的代码行在PowerPoint VBA中有效吗?而且,看看你发布的代码,当你已经实例化了
oPPTFile
,不要使用
ActivePresentation
-使用它。@Cindymister,我不能100%确定footer.text是否在VBA中工作。我要么得到有关ActiveX的错误代码,要么得到一条错误消息,指出“HeaderFooter”是未知成员。