老哥们,小弟(纯小白)之前在网上找到这么一段代码,用来按照指定的页数间隔来分割PPT,现在如果我想用每一页的内容(比方说每页有固定的标题)做为分割后的文件名又该如何修改这段代码?求指教,感激不尽。
Option Explicit
Sub SplitSlides()
Dim oSrcPresentation As Presentation, oNewPresentation As Presentation
Dim strSrcFileName As String, strNewFileName As String
Dim nIndex As Integer, nSubIndex As Integer, nTotalSlides As Integer, nBound As Integer, nCounter As Integer
Dim fso As Object
Const nSteps = 5 ' 修改这里控制每隔几页分割一次
If nSteps <= 0 Then Exit Sub
Set fso = CreateObject("Scripting.FileSystemObject")
Set oSrcPresentation = ActivePresentation
strSrcFileName = oSrcPresentation.FullName
nTotalSlides = oSrcPresentation.Slides.Count
nCounter = 1
For nIndex = 1 To nTotalSlides Step nSteps
If nIndex + nSteps > nTotalSlides Then
nBound = nTotalSlides
Else
nBound = nIndex + nSteps - 1
End If
strNewFileName = fso.BuildPath(fso.GetParentFolderName(strSrcFileName), _
fso.GetBaseName(strSrcFileName) & "_" & nCounter & "." & fso.GetExtensionName(strSrcFileName))
oSrcPresentation.SaveCopyAs strNewFileName
Set oNewPresentation = Presentations.Open(strNewFileName)
If nBound < nTotalSlides Then
For nSubIndex = nBound + 1 To nTotalSlides
oNewPresentation.Slides(nBound + 1).Delete
Next
End If
If nIndex > 1 Then
For nSubIndex = 1 To nIndex - 1
oNewPresentation.Slides(1).Delete
Next
End If
oNewPresentation.Save
oNewPresentation.Close
nCounter = nCounter + 1
Next nIndex
MsgBox "结束!", vbInformation
End Sub
Option Explicit
Sub SplitSlides()
Dim oSrcPresentation As Presentation, oNewPresentation As Presentation
Dim strSrcFileName As String, strNewFileName As String
Dim nIndex As Integer, nSubIndex As Integer, nTotalSlides As Integer, nBound As Integer, nCounter As Integer
Dim fso As Object
Const nSteps = 5 ' 修改这里控制每隔几页分割一次
If nSteps <= 0 Then Exit Sub
Set fso = CreateObject("Scripting.FileSystemObject")
Set oSrcPresentation = ActivePresentation
strSrcFileName = oSrcPresentation.FullName
nTotalSlides = oSrcPresentation.Slides.Count
nCounter = 1
For nIndex = 1 To nTotalSlides Step nSteps
If nIndex + nSteps > nTotalSlides Then
nBound = nTotalSlides
Else
nBound = nIndex + nSteps - 1
End If
strNewFileName = fso.BuildPath(fso.GetParentFolderName(strSrcFileName), _
fso.GetBaseName(strSrcFileName) & "_" & nCounter & "." & fso.GetExtensionName(strSrcFileName))
oSrcPresentation.SaveCopyAs strNewFileName
Set oNewPresentation = Presentations.Open(strNewFileName)
If nBound < nTotalSlides Then
For nSubIndex = nBound + 1 To nTotalSlides
oNewPresentation.Slides(nBound + 1).Delete
Next
End If
If nIndex > 1 Then
For nSubIndex = 1 To nIndex - 1
oNewPresentation.Slides(1).Delete
Next
End If
oNewPresentation.Save
oNewPresentation.Close
nCounter = nCounter + 1
Next nIndex
MsgBox "结束!", vbInformation
End Sub