Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check harddisk space

Status
Not open for further replies.

jack1080

Programmer
Jun 2, 2007
34
MY
Hi, i wish to check the user C drive remaining spaces using vba, how to do this?
 
This is somewhere here.. I can't find the thread

Code:
Function ShowFreeSpace(Optional drvPath = "C:")
   Dim fso, d, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set d = fso.GetDrive(fso.GetDriveName(drvPath))
   s = "Drive " & UCase(drvPath) & " - "
   s = s & d.VolumeName & vbCrLf
   s = s & "Total Size: " & FormatNumber(d.TotalSize / 1024, 0) & " Kbytes" & vbCrLf
   s = s & "Free Space: " & FormatNumber(d.FreeSpace / 1024, 0) & " Kbytes"
   ShowFreeSpace = s
End Function
'=========================================
Private Sub Command0_Click()
MsgBox ShowFreeSpace
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top