【发布时间】:2019-06-15 17:43:29
【问题描述】:
我们通常使用 powerpoint 来促进我们的实验。我们在 powerpoint 中使用“部分”来为每个实验任务保留一组幻灯片。移动部分以平衡实验的任务顺序是一项艰巨的工作!
我认为我们可以在 CSV 或数组中预定义一个平衡订单(使用代表订单的数字字符串)(还没有在 VBA 中构建出来)。然后使用 VBA 移动部分并为每个订单保存文件。我对使用 VBA 很生疏,但我认为我有一个很好的开始。问题出在第 24 行。我不知道如何将该部分复制到新的演示文稿中。有没有足够熟悉的人引导我走上正确的道路。
Sub Latin_Square()
Dim amountOfSubjects As Integer
'Declare the amount of subjects you have in your study
amountOfSubjects = 14
Dim filePath As String
filePath = "C:/1.pptx"
Dim amountofsections As Integer
Dim i As Integer
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim desktopPath As String
'find out where user's desktop is
desktopPath = Environ("UserProfile") & "\Desktop\"
Dim oldPresentation As Presentation
Dim newPresentation As Presentation
'open the target presentation
Set oldPresentation = Presentations.Open("C:\1.pptx")
For i = 1 To oldPresentation.Slides.Count
oldPresentation.Slides.Item(i).Copy
newPresentation.Item(1).Slides.Paste
Next i
oldPresentation.Close
With newPresentation
.SaveCopyAs _
FileName:=fso.BuildPath(desktopPath, "Test" & 1 & ".pptx"), _
FileFormat:=ppSaveAsOpenXMLPresentation
End With
End Sub
【问题讨论】:
标签: vba powerpoint sections copying