ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA compatible code - PC to Mac (https://www.excelbanter.com/excel-programming/427835-vba-compatible-code-pc-mac.html)

c1802362[_2_]

VBA compatible code - PC to Mac
 
Does anyone know if there is a comparable VBA function on the Mac to

Application.FileSearch.FoundFiles.Count on the PC?

I'm running excel 2004 for Mac 11.5.4/VBA 11.5

Art

joel

VBA compatible code - PC to Mac
 
I don't have a MAC but see if this code works. if it does I will modify it
to do what you want. The code gets size of all subfolders on the c drive and
put the info on a worksheet. I think for MAC's you have to change the
backshalsh ("\") to a colon (":") for it to work. I also was told that on
PC's for excel 2007 the filesearch was not included in excel 2007 but an
update added the function. I would also try going to Microsoft.com and
getting all the latest updates for excel and vista.

Dim RowNumber
Sub GetFolderSize()

strFolder = "C:"
RowNumber = 1

Set FSO = CreateObject _
("Scripting.FileSystemObject")
Set Folder = _
FSO.GetFolder(strFolder)

Sheets(1).Cells(RowNumber, 1) = strFolder + "\"
Sheets(1).Cells(RowNumber, 2) = Folder.Size
RowNumber = RowNumber + RowNumber

Call GetSubFolder(strFolder + "\")
End Sub

Sub GetSubFolder(strFolder)
Set FSO = CreateObject _
("Scripting.FileSystemObject")

Set Folder = _
FSO.GetFolder(strFolder)

If Folder.subfolders.Count 0 Then
For Each sf In Folder.subfolders
On Error GoTo 100
Call GetSubFolder(strFolder + sf.Name + "\")
100 Next sf
End If
'folder size in bytes
On Error GoTo 200
For Each fl In Folder.Files
Sheets(1).Cells(RowNumber, 3) = fl.DateLastModified
Sheets(1).Cells(RowNumber, 2) = fl.Size
Sheets(1).Cells(RowNumber, 1) = strFolder & fl.Name
RowNumber = RowNumber + 1
Next fl

200 On Error GoTo 0

End Sub


"c1802362" wrote:

Does anyone know if there is a comparable VBA function on the Mac to

Application.FileSearch.FoundFiles.Count on the PC?

I'm running excel 2004 for Mac 11.5.4/VBA 11.5

Art



All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com