Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Determining hard drive space remaining

In Excel VBA (2002), how can I determine the amount of remaining hard drive
space? C:\ drive and D:\ drive.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Determining hard drive space remaining

You can use the same method as presented he

http://support.microsoft.com/default...b;en-us;225144
HOWTO: Use GetDiskFreeSpaceEx to Retrieve Drive Information

This method is limited to 2GB results:

http://support.microsoft.com/default...b;en-us;153091
How To Find and View the Amount of Free Disk Space on a Drive

--
Regards,
Tom Ogilvy


"Bullfrog1870" wrote in message
...
In Excel VBA (2002), how can I determine the amount of remaining hard

drive
space? C:\ drive and D:\ drive.

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Determining hard drive space remaining

Hi everybody,

how about something very oldfashioned:

"c:\Mydir.Bat" containing:
dir c:\dir.txt /b

Plus:

Sub test099881()
Shell "c:\mydir.bat"
Dim sTmp As String
Open "c:\dir.txt" For Input As #1
While Not EOF(1)
Line Input #1, sTmp
Wend
Close #1
sTmp = Right(sTmp, Len(sTmp) - InStr(sTmp, "(s)") - 4)
sTmp = Left(sTmp, Len(sTmp) - 11)
MsgBox CDbl(sTmp)
End Sub

Not meant too seriously, and restricted to english version,
but when doing some kind of statistics
on a server with more than 350,000 files,
the dir-command was the only thing that worked.


--
regards

Helmut Weber, MVP WordVBA

"red.sys" & chr$(64) & "t-online.de"
Win XP, Office 2003





You can use the same method as presented he

http://support.microsoft.com/default...b;en-us;225144
HOWTO: Use GetDiskFreeSpaceEx to Retrieve Drive Information

This method is limited to 2GB results:

http://support.microsoft.com/default...b;en-us;153091
How To Find and View the Amount of Free Disk Space on a Drive


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Determining hard drive space remaining

Doesn't that just list the filenames?

Plus a msgbox only accomodates a 255 character string, so I guess you don't
mean the code you provided literally worked with 350,000 files. <g

--
Regards,
Tom Ogilvy

"Helmut Weber" wrote in message
...
Hi everybody,

how about something very oldfashioned:

"c:\Mydir.Bat" containing:
dir c:\dir.txt /b

Plus:

Sub test099881()
Shell "c:\mydir.bat"
Dim sTmp As String
Open "c:\dir.txt" For Input As #1
While Not EOF(1)
Line Input #1, sTmp
Wend
Close #1
sTmp = Right(sTmp, Len(sTmp) - InStr(sTmp, "(s)") - 4)
sTmp = Left(sTmp, Len(sTmp) - 11)
MsgBox CDbl(sTmp)
End Sub

Not meant too seriously, and restricted to english version,
but when doing some kind of statistics
on a server with more than 350,000 files,
the dir-command was the only thing that worked.


--
regards

Helmut Weber, MVP WordVBA

"red.sys" & chr$(64) & "t-online.de"
Win XP, Office 2003





You can use the same method as presented he

http://support.microsoft.com/default...b;en-us;225144
HOWTO: Use GetDiskFreeSpaceEx to Retrieve Drive Information

This method is limited to 2GB results:

http://support.microsoft.com/default...b;en-us;153091
How To Find and View the Amount of Free Disk Space on a Drive




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Determining hard drive space remaining

Hi Tom,

Doesn't that just list the filenames?


the filenames in the start directory plus the summary.
The disk space left would be in the last line, like:

Volume in drive C has no label.
Volume Serial Number is 6859-3ECC

Directory of C:\Edit2003

2005-12-04 22:08 <DIR .
2005-12-04 22:08 <DIR ..
[some entries deleted manually]
2005-11-18 12:51 23,552 Word-Edit.doc
2005-11-18 12:51 55,296 Word-Edit.dot
2005-09-24 09:15 88,064 xNormal.dot
2005-11-17 17:38 249,856 _Normal.dot
17 File(s) 1,502,396 bytes
2 Dir(s) 35,565,920,256 bytes free

Plus a msgbox only accomodates a 255 character string, so I guess you don't
mean the code you provided literally worked with 350,000 files. <g


That was another scenario, I shouldn't have mentioned, maybe.
dir *.* /s dir.txt
gives you list of all files, from whereever you start,
plus the summary.
With more than a hundred users collecting all kind
of rubbish for years it may last for hours.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"











  #6   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Determining hard drive space remaining

you can try the code below. But you need to make sure in your reference, you
check the Microsoft Scripting Runtime library:

Sub test()
Dim oFSO As FileSystemObject
Dim strDrive As Drive

Set oFSO = New FileSystemObject
Set strDrive = oFSO.GetDrive("C:\")
MsgBox FormatNumber(strDrive.FreeSpace / 1024, 0)


End Sub

--



"Bullfrog1870" wrote:

In Excel VBA (2002), how can I determine the amount of remaining hard drive
space? C:\ drive and D:\ drive.

Thanks.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Determining hard drive space remaining

Actually, using the /b argument as you suggested suppresses the summary
information of which you speak. Tested in Windows 98 SE and Windows XP to
be sure I am not speaking out of turn. This is also the expected behavior
according to the help on DIR. Perhaps you didn't mean to include the /b.

--
Regards,
Tom Ogilvy

"Helmut Weber" wrote in message
...
Hi Tom,

Doesn't that just list the filenames?


the filenames in the start directory plus the summary.
The disk space left would be in the last line, like:

Volume in drive C has no label.
Volume Serial Number is 6859-3ECC

Directory of C:\Edit2003

2005-12-04 22:08 <DIR .
2005-12-04 22:08 <DIR ..
[some entries deleted manually]
2005-11-18 12:51 23,552 Word-Edit.doc
2005-11-18 12:51 55,296 Word-Edit.dot
2005-09-24 09:15 88,064 xNormal.dot
2005-11-17 17:38 249,856 _Normal.dot
17 File(s) 1,502,396 bytes
2 Dir(s) 35,565,920,256 bytes free

Plus a msgbox only accomodates a 255 character string, so I guess you

don't
mean the code you provided literally worked with 350,000 files. <g


That was another scenario, I shouldn't have mentioned, maybe.
dir *.* /s dir.txt
gives you list of all files, from whereever you start,
plus the summary.
With more than a hundred users collecting all kind
of rubbish for years it may last for hours.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"











  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Determining hard drive space remaining

Hi Tom,

I am ashamed, maybe I should finally forget about DOS-times.

Actually, using the /b argument as you suggested
suppresses the summary information of which you speak.


Not if you put the /b switch in the wrong place,
like I did in my first posting in this thread.

Where I put it, it does nothing at all. :-(

Thank you.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HARD DRIVE DENISE New Users to Excel 7 March 11th 09 08:06 PM
Links to mapped drive change to refer to local hard drive SueD Links and Linking in Excel 1 May 8th 08 11:42 AM
Can I save to hard drive AND my flash drive at the same time? Gizelle Excel Discussion (Misc queries) 3 July 24th 06 08:27 PM
files opening from hard drive without prompt, aFrank from Auburn, CA, Ahumdalaha Excel Programming 2 September 18th 04 01:15 PM
Erase Hard Drive Mark C[_4_] Excel Programming 2 February 27th 04 09:24 AM


All times are GMT +1. The time now is 10:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"