Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default system calls in excel

Is it possible to get the properties of a folder/drive from within an Excel
macro and then populate seperate cells with the folder/drive size, number of
files & number of folders?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default system calls in excel

Yes: use FileSystemObject
I'm not sure about folder size.

HTH
--
AP

"Damon" a écrit dans le message de news:
...
Is it possible to get the properties of a folder/drive from within an
Excel
macro and then populate seperate cells with the folder/drive size, number
of
files & number of folders?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default system calls in excel

Thank you, that appears to be the instruction I need but can anybody tell me
how I would use it get the properties for a folder and then copy the
infomation I need (Folder size, Number of files & Number of folders) into
seperate cells within excel?

Thank you in advance

"Ardus Petus" wrote:

Yes: use FileSystemObject
I'm not sure about folder size.

HTH
--
AP

"Damon" a écrit dans le message de news:
...
Is it possible to get the properties of a folder/drive from within an
Excel
macro and then populate seperate cells with the folder/drive size, number
of
files & number of folders?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default system calls in excel

Hello Damon
Here is a try (please amend accordingly)
Cordially
Pascal

Sub Test()
GetInfo "C:\My documents\Excel\samples", 0
End Sub
Function GetInfo(Foldername$, Indx As Long)
Dim RootFolder As Object
Dim SubFldr As Object
Dim NewFldr As String
Dim fso As Object
Dim i As Long
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set RootFolder = fso.GetFolder(Foldername)
If Err < 0 Then
MsgBox "Folder " & Foldername & " was not found", vbInformation, "Not found"
Exit Function: End If
With ActiveWorkbook.Worksheets(1)
i = Indx
..Cells(i + 1, 1).Value = "Folder Name"
..Cells(i + 1, 2).Value = Foldername
..Cells(i + 2, 1).Value = "No of subFolders"
..Cells(i + 2, 2).Value = RootFolder.SubFolders.Count
..Cells(i + 3, 1).Value = "Folder size"
..Cells(i + 3, 2).Value = Format((RootFolder.Size) / 1024, "#,##0")
..Cells(i + 4, 1).Value = "No of Files"
..Cells(i + 4, 2).Value = RootFolder.Files.Count
End With
'if sub folders found then call recursively
If RootFolder.SubFolders.Count 0 Then
For Each SubFldr In RootFolder.SubFolders
i = i + 6
NewFldr = SubFldr.Path
GetInfo NewFldr, i
Next SubFldr
End If
End Function


"Damon" a écrit dans le message de news:
...
Thank you, that appears to be the instruction I need but can anybody tell
me
how I would use it get the properties for a folder and then copy the
infomation I need (Folder size, Number of files & Number of folders) into
seperate cells within excel?

Thank you in advance

"Ardus Petus" wrote:

Yes: use FileSystemObject
I'm not sure about folder size.

HTH
--
AP

"Damon" a écrit dans le message de
news:
...
Is it possible to get the properties of a folder/drive from within an
Excel
macro and then populate seperate cells with the folder/drive size,
number
of
files & number of folders?






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default system calls in excel

Thank you both for you help, both examples give me the results I require and
help me to understand programming excel/macros better.

"Damon" wrote:

Thank you, that appears to be the instruction I need but can anybody tell me
how I would use it get the properties for a folder and then copy the
infomation I need (Folder size, Number of files & Number of folders) into
seperate cells within excel?

Thank you in advance

"Ardus Petus" wrote:

Yes: use FileSystemObject
I'm not sure about folder size.

HTH
--
AP

"Damon" a écrit dans le message de news:
...
Is it possible to get the properties of a folder/drive from within an
Excel
macro and then populate seperate cells with the folder/drive size, number
of
files & number of folders?




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
How do I open an Excel file on XP system, saved on a Vista system JLS7 Excel Discussion (Misc queries) 3 December 2nd 08 04:21 AM
Excel calls for Save ~Boles³aw Cienki Excel Discussion (Misc queries) 2 August 25th 06 05:21 PM
vbcsript calls excel macro vedran Excel Programming 1 May 10th 06 11:13 PM
excel causing system to be in low system resource inenewbl Excel Discussion (Misc queries) 0 April 5th 05 04:11 PM
MP3 ID3 API Calls for excel Chad Cameron[_3_] Excel Programming 11 December 20th 04 08:34 PM


All times are GMT +1. The time now is 05:46 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"