|
楼主 |
发表于 2024-3-2 18:27
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
自己出题自己做
- '''
- Sub DictPptSingsDelFile()
- Dim T: T = Time
- Dim Fso As FileSystemObject, oFolder As Folder, oFile As File
- Set Fso = New FileSystemObject
- Debug.Print Format(T, "h;mm:ss")
- Dim RngDic As Dictionary, SldDic As Dictionary
- Dim FileRng As Range, FileDic As Dictionary
- Set RngDic = New Dictionary
- Set SldDic = New Dictionary
- Set FileDic = New Dictionary
- Dim Rng As Range, Sht As Worksheet
- Set Rng = Selection
- Set Sht = Rng.Parent
- Set Rng = Sht.Cells(20, 1).CurrentRegion
- Rng.Resize(Rng.Rows.Count, 26).Interior.Color = vbRed
-
- Rng.Resize(Rng.Rows.Count, 26).Interior.ColorIndex = xlNone
- Dim PathName, oPath, Str
- Dim Pres As Presentation, Slds As Slides
- Dim Hor As Boolean
- Hor = False
- ''
- If Hor = True Then
- PathName = ThisWorkbook.Path & "" & Sht.Name & "\Hor" & Sht.Name & ".Ppt"
- ElseIf Hor = False Then
- PathName = ThisWorkbook.Path & "" & Sht.Name & "\Ver" & Sht.Name & ".Ppt"
- End If
-
- Debug.Print PathName
- oPath = ThisWorkbook.Path & "" & Sht.Name
-
- Set oFolder = Fso.GetFolder(oPath)
- Set oFiles = oFolder.Files
- Set Pres = OpenPpt(PathName)
- Set Slds = Pres.Slides
- Dim Arr, Rr, ii, jj
- Dim Sld As Slide
- For Each Sld In Slds
- Sld.Name = Sld.Shapes(1).Name
- SldDic(UCase(Sld.Name)) = "" ''
- Next Sld
- '''
- For Each oFile In oFiles
- If InStr(UCase(oFile.Name), "JPG") > 0 Then
- 'Debug.Print oFile.Name
- FileDic(oFile.Name) = ""
- Debug.Print oFile.Path
- End If
- Next oFile
- '''
- Kk = 1
- Set Rng = Sht.Cells(Rng.Row + Rng.Rows.Count + 20, 1).Resize(1000, 10)
- '''
- Rng.Clear
- For ii = 0 To FileDic.Count - 1
- Str = UCase(FileDic.Keys(ii))
- 'Str = Mid(Str, 2, 100)
- If Not SldDic.Exists(Str) Then
- Sht.Cells(Rng.Row + Kk, 1) = Kk
- Sht.Cells(Rng.Row + Kk, 2) = Str
- Str = ThisWorkbook.Path & "" & Sht.Name & "" & FileDic.Keys(ii)
-
- Set oFile = Fso.GetFile(Str)
- oFile.Move "D:\Tmp"
- Kk = Kk + 1
- End If
- Next ii
- '''
- 'Set oRng = Sht.Cells(Rng.Row + Rng.Rows.Count + Kk - 10, 1).CurrentRegion
- Debug.Print Sht.Cells(Rng.Row - 5, 1).Address, Kk
- Sht.Cells(Rng.Row - 5, 1) = "=count(" & Rng.Resize(Kk + 2, 1).Address(0, 0) & ")"
-
- Debug.Print Format(Time - T, "h;mm:ss")
- 'Pres.Save
- Debug.Print Format(Time - T, "h;mm:ss")
- End Sub
- ''
- '''''''
复制代码 |
|