Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Check Drive Space

Hi is it possible to write code to check available space
on a drive from Excel?.
TIA
Charles
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Check Drive Space

Here is a routine posted by Jim Rech a while back

Declare Function GetDiskFreeSpaceExA Lib "kernel32" _
(ByVal lpDirectoryName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfBytes As Currency) As Boolean

Sub ShowDiskSpace()
Dim MyFreeSpace As Currency
Dim MyTotalSpace As Currency
Dim TotalFreeSpace As Currency
If GetDiskFreeSpaceExA("c:\", _
MyFreeSpace, _
MyTotalSpace, _
TotalFreeSpace) Then
MyFreeSpace = MyFreeSpace * 10000
MyTotalSpace = MyTotalSpace * 10000
TotalFreeSpace = TotalFreeSpace * 10000
MsgBox "Total space on drive: " & _
Format(MyTotalSpace, "#,###bytes") & Chr(13) & _
"Free space: " & Format(MyFreeSpace, "#,### bytes")
End If
End Sub



--

HTH

RP

"Charles" wrote in message
...
Hi is it possible to write code to check available space
on a drive from Excel?.
TIA
Charles



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Check Drive Space

a bit simpler alternative to using api..

Function FreeKB(DriveSpec As String)
With CreateObject("Scripting.FileSystemObject")
If Not .DriveExists(DriveSpec) Then
FreeKB = CVErr(xlErrRef)
Else
FreeKB = .GetDrive(DriveSpec).FreeSpace \ 1024
End If
End With
End Function



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Charles" wrote:

Hi is it possible to write code to check available space
on a drive from Excel?.
TIA
Charles


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Check Drive Space

but depends upon Scripting being allowed, not true in many commercial
environments

--

HTH

RP

"keepITcool" wrote in message
...
a bit simpler alternative to using api..

Function FreeKB(DriveSpec As String)
With CreateObject("Scripting.FileSystemObject")
If Not .DriveExists(DriveSpec) Then
FreeKB = CVErr(xlErrRef)
Else
FreeKB = .GetDrive(DriveSpec).FreeSpace \ 1024
End If
End With
End Function



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Charles" wrote:

Hi is it possible to write code to check available space
on a drive from Excel?.
TIA
Charles




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
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
Getting Amount Free Disk Space On A Drive mrclinker Excel Discussion (Misc queries) 2 May 12th 06 01:16 PM
Pasting a range of information from a foler on F Drive to another folder on same drive Tom Ogilvy Excel Programming 1 August 3rd 03 01:50 AM
Find links with code; change from G drive to C drive Sandy[_3_] Excel Programming 4 July 26th 03 07:24 PM


All times are GMT +1. The time now is 04:42 PM.

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"