ファイルの種類を取得するマクロです。
例
ファイルの種類を取得するには、FileSystemObjectのGetFileでファイルオブジェクトを取得し、そのTypeプロパティからファイルの種類を取得します。※このFileSystemObjectを使うには、あらかじめ参照設定で「Microsoft Scripting Runtime」にチェックを入れておく必要があります。

Sub GetFileType()
Dim fso As New FileSystemObject
Dim filePath As String
filePath = "C:\work\image1\cccc.jpg"
MsgBox filePath & vbCrLf & vbCrLf & "ファイルタイプは、『 " & fso.GetFile(filePath).Type & " 』です。", vbInformation, "FileSystemObject"
End Sub
実行結果

comments powered by Disqus
スポンサーリンク