Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpcurRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long
Sub FreeBytes(NetworkShare As String)
Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim curTotalFreeBytes As Currency
Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)
'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Debug.Print " Total Number Of Bytes:", _
Format$(curTotalBytes * 10000, "###,###,###,##0") & " bytes"
Debug.Print " Total Free Bytes:", _
Format$(curTotalFreeBytes * 10000, "###,###,###,##0") & " bytes"
Debug.Print " Free Bytes Available:", _
Format$(curBytesFreeToCaller * 10000, "###,###,###,##0") & " bytes"
Debug.Print " Total Space Used :", _
Format$((curTotalBytes - curTotalFreeBytes) * 10000,
"###,###,###,##0") & " bytes"
End Sub