Sub 指定したドライブの容量を調べる() Dim fso As New Scripting.FileSystemObject Dim myTotal As Variant Dim mySpace As Variant With fso.GetDrive(Range("B1").Value) myTotal = .TotalSize mySpace = .AvailableSpace End With Range("B2").Value = Format(myTotal - mySpace, "#,##0") Range("B3").Value = Format(mySpace, "#,##0") Range("B4").Value = Format(myTotal, "#,##0") Set fso=Nothing End Sub Driveオブジェクトを取得するFileSystemOb
![VBAにおけるFileDialog/エクスプローラー操作の基本&ドライブの空き容量、ファイルのサイズやタイムスタンプの取得方法](https://cdn-ak-scissors.b.st-hatena.com/image/square/d3a3512a3998f9d84b102f171dfb48436d94af4f/height=288;version=1;width=512/https%3A%2F%2Fimage.itmedia.co.jp%2Fait%2Farticles%2F1707%2F10%2Fl_news023_9_03.jpg)