-Agregar la referencia a Microsoft Scripting.FileSystemObject
-Recuperar y navegar en la colección de los discos y escribir las propiedades en las celdas.
Sub Read_Drives_In_Excel_VBA()
'Excel VBA CODE-MyExcelTools.com
On Error Resume Next
Dim fso
'Declare the variable
'Set the object type Scripting
Set fso = CreateObject("Scripting.FileSystemObject")
'Set the drives collection
Set Drives = fso.Drives
Dim count As Byte
For Each u In Drives
'Recorremos la colección
'Drive
Columns(1).Cells(1).Offset(count, 0).Value = u.DriveLetter
'Free Space
Columns(2).Cells(1).Offset(count, 0).Value = FormatNumber(u.AvailableSpace / 1024 / 1024 / 1024, 2, , , -1)
count = count + 1
Next
'clear the objects
Set Drives = Nothing
Set fso = Nothing
End Sub
No hay comentarios:
Publicar un comentario