On Sat, 2 Oct 2004 20:25:23 +0100, "Deano" <ma**********@gmail.com>
wrote:
Given a drive letter is there some cut and paste code out there that will
check the space remaining?
I want to be able to warn the user if the backup operation might not succeed
due to a lack of diskspace.
Haven't been able to track down what I need hence the post.
thanks
Martin
Hi
Here's an amusing way of doing it. The free space can exceed long.
Set refs to include Microsoft Scripting Runtime
Function testit()
Dim FreeString As String
MsgBox "Free space on C is " & GetFreeSpace("C")
End Function
Private Function GetFreeSpace(ByVal strDriveLetter As String) As
Currency
Dim fso As Scripting.FileSystemObject
Dim dr As Scripting.Drive
Set fso = New Scripting.FileSystemObject
GetFreeSpace = fso.GetDrive(strDriveLetter).FreeSpace
Set fso = Nothing
End Function
Incidentally I found this out by typing "disk free space vba" into
Google and looking at the first reference returned. I did change it to
use the currenct type however!
David