Reputation: 303
How can I change the below drive letter from P to use network full path name instead?
I cant seem to figure it out
'Creating a FileSystemObject
Public FSO As New FileSystemObject
Sub DiskSpace()
Dim drv As Drive
Dim Space As Double
Set drv = FSO.GetDrive("P:") ' Creating the the Drive object
Space = drv.FreeSpace
Space = Space / 1073741824 'converting bytes to GB
Space = WorksheetFunction.Round(Space, 2) ' Rounding
MsgBox "P: has free space = " & Space & " GB"
End Sub
Upvotes: 0
Views: 10494
Reputation: 60464
Modify to suit:
Dim FSO As FileSystemObject
Dim DRV As Drive
Dim FO As Folder
Dim sPath As String
sPath = "\\RON-DODIER\Users" 'Network Folder Path
Set FSO = New FileSystemObject
Set FO = FSO.GetFolder(sPath)
Debug.Print FO.Drive.FreeSpace
You can also use the Drive property of the File object, if that is more what you want, to determine the amount of free space.
Upvotes: 3