我有一个包含多个PowerPoint文件的文件夹,其中一些重复并且在末尾附加了2个字符。因此这些重复的文件具有相同的文件名,但后两个字符除外,即_1或_2或_3或_5。我正在尝试通过合并具有相同名称(最后两个字符除外)的文件来将所有重复的文件组合回一个文件,并删除重复的文件。 Pls see example list of files
我可以使用PPTools的此代码将所有文件合并到一个文件夹中,但是有人可以建议如何在文件名末尾引入条件检查2个通配符(??)。
Sub InsertAllSlides()
Dim vArray() As String
Dim x As Long
' Change "*.PPT" to "*.PPTX" or whatever if necessary:
EnumerateFiles ActivePresentation.Path & "\", "*.PPT", vArray
With ActivePresentation
For x = 1 To UBound(vArray)
If Len(vArray(x)) > 0 Then
.Slides.InsertFromFile vArray(x), .Slides.Count
End If
Next
End With
End Sub
Sub EnumerateFiles(ByVal sDirectory As String, ByVal sFileSpec As String, ByRef vArray As Variant)
' collect all files matching the file spec into vArray, an array of strings
Dim sTemp As String
ReDim vArray(1 To 1)
sTemp = Dir$(sDirectory & sFileSpec)
Do While Len(sTemp) > 0
' NOT the "mother ship" ... current presentation
If sTemp <> ActivePresentation.Name Then
ReDim Preserve vArray(1 To UBound(vArray) + 1)
vArray(UBound(vArray)) = sDirectory & sTemp
End If
sTemp = Dir$
Loop
End Sub