|
- Sub MovePicToFolder()
- Dim FSO As Scripting.FileSystemObject
- Dim oFolder As Scripting.Folder
- Set FSO = New Scripting.FileSystemObject
- Dim Sht As Worksheet
- Dim Rng As Range, oRng As Range
- Dim PathFile, oPath
- Dim SourceFile, DestinationFolder
- Set Sht = Sheets("t")
- Set Rng = Sht.Cells(5, 1).CurrentRegion
- Debug.Print Rng.Address
- For ii = 1 To Rng.Rows.Count
- Set Sht = ThisWorkbook.Sheets(Format(Rng(ii, 1), "yyyy年m月"))
- Sht.Activate
- 'Debug.Print Sht.Name
- Set oRng = Sht.Cells(5, 3).CurrentRegion
- Debug.Print oRng.Address,
- Set oRng = oRng.Resize(oRng.Rows.Count - 1, 9)
- Debug.Print oRng.Address,
- For ii1 = 1 To oRng.Rows.Count
- ''
- SourceFile = oRng(ii1, 9)
- Debug.Print FSO.FileExists(SourceFile), SourceFile, oRng(ii1, 9).Address,
- ''
- If FSO.FileExists(SourceFile) Then
- oPath = ThisWorkbook.Path & "" & Sht.Name & "" & oRng(ii1, 6)
- DestinationFolder = ThisWorkbook.Path & "" & Sht.Name & "" '& oRng(ii, 6)
- Debug.Print oPath, DestinationFolder,
- Debug.Print FSO.FileExists(oPath)
-
- If Not FSO.FileExists(oPath) Then
- FSO.MoveFile SourceFile, DestinationFolder
- End If
- End If
-
- Debug.Print PathFile, oPath
- Next ii1
- Debug.Print "--------------"
- Next ii
- End Sub
复制代码 |
|