Getting Amount Free Disk Space On A Drive

M

mrclinker

Dear experts:

I want to get the amount of free disk space on a drive or network
mapped drive, and store it in a cell. ¿How can you do that?

Thank you very much,

Mr.Clinker
Uruguay
 
B

Bob Phillips

Function GetDriveSpace(DriveLetter As String)
Dim oFSO As Object, oDrive As Object
If Right(DriveLetter, 1) <> ":" Then DriveLetter = DriveLetter & ":"
Set oFSO = CreateObject("Scripting.FileSystemobject")
Set oDrive = oFSO.getDrive(DriveLetter)
GetDriveSpace = oDrive.freespace
Set oDrive = Nothing
Set oFSO = Nothing
End Function


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 
A

Ardus Petus

In VBE: Tools>References tick Microsoft Scripting Runtime

Function FreeSpace(sDriveName As String)
Static oFSO As FileSystemObject
If oFSO Is Nothing Then Set oFSO = New FileSystemObject
FreeSpace = oFSO.GetDrive(sDriveName).FreeSpace
End Function

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top