- VB,VBA
-
2011-09-30 - 更新:2017-06-14
Visual BasicでFileSystemObjectを使用し、
指定したディレクトリ内の全ファイル(サブディレクトリを含む)を読み込む。
全階層を再帰的に検索することができます。
■コマンドボタンに以下のようにコードを記述
Private Sub ファイル検索_Click() Dim strPath As String Dim fsObj As Object If Not IsNull("検索文字列") Then Set fsObj = CreateObject("Scripting.FileSystemObject") strPath = "調べたいディレクトリまでのフルパス" strKey = "検索文字列" 'ディレクトリ読み込み関数を呼び出し Call SearchSubDirectory(fsObj.GetFolder(strPath), strKey) 'オブジェクトを破棄 Set fsObj = Nothing End If End Sub
![](https://k-sugi.sakura.ne.jp/wp-content/themes/chic_grid3/images/icon-tag.png)
13,400 views