ファイル属性変更(再起処理)' 再帰的に指定フォルダ以下のファイル属性を設定する(Normal) ' 【参照設定】Microsoft Scripting Runtime Public Sub ChAttr(sDirPath As String) ' 変数定義 Dim oFSO As FileSystemObject Dim oFolder As Folder Dim oSubFolder As Folder Dim oFile As File ' FileSystemObject Set oFSO = CreateObject("Scripting.FileSystemObject") ' 引数で渡されたパスが存在しなければ処理中断 If Not oFSO.FolderExists(sDirPath) Then Exit Sub End If ' Folderオブジェクト参照 Set oFolder = oFSO.GetFolder(sDirPath) ' サブフォルダがあれば再帰処理 For Each oSubFolder In oFolder.SubFolders Call ChAttr(oSubFolder.Path) Next ' フォルダ内のファイル属性を Normal に設定 For Each oFile In oFolder.Files oFile.Attributes = Normal Next ' オブジェクトの開放 Set oFile = Nothing Set oSubFolder = Nothing Set oFolder = Nothing Set oFSO = Nothing End Sub ジャンル別一覧
人気のクチコミテーマ
|