Добрый вечер!
Полез в изучение file system objects... как всегда застрял...
Прошу помочь с такой ситуацией: нужно, например, копировать файл, если название файла содержит "-"
Вот код
[vba]Код
Option Explicit
Sub UsingTheScriptingRunTimeLibrary()
Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.file
Dim OldFolder As Scripting.Folder
Dim NewFolderPath As String
Dim OldFolderPath As String
NewFolderPath = "C:\Users\Anton\Deskto...."
OldFolderPath = "C:\Users\Ant....."
Set fso = New Scripting.FileSystemObject
If fso.FolderExists(OldFolderPath) Then
Set OldFolder = fso.GetFolder(OldFolderPath)
If Not fso.FolderExists(NewFolderPath) Then
fso.CreateFolder NewFolderPath
End If
For Each fil In OldFolder.Files
' If Left(fso.GetExtensionName(fil.Path), 2) = "xl" Then
' If fso.GetExtensionName(fil.Path) = "xlsx" Then
If fso.GetFileName(fil.Path) = ("*" & "-" & "*") Then
' If fil.Name = ("*" & "-" & "*") Then
' fil.Copy NewFolderPath & "\" & fil.Name
Workbooks.Open (fil)
' Debug.Print fil.Name
' Else: MsgBox "No files with xls extesion found"
End If
' Debug.Print fil.Name
Next fil
End If
Set fso = Nothing
End Sub
[/vba]