
ReDim rm_List(1 to 1)
For Each ds in Lecteur.Drives
's'il ya plus d'un lecteur Réseau à trouver rassembler dans un tableau.
if ds.DriveType = 3 Then _
n = n + 1: Redim Preserve rm_List( 1 to n): rm_List(n) = ds.ShareName
'sinon
nom = ds.ShareName
Next |
Sub listadrives()
Dim ds As Object
ReDim rm_List(1 To 1)
For Each ds In Lecteur.Drives
's'il ya plus d'un lecteur Réseau à trouver rassembler dans un tableau.
If ds.DriveType = 3 Then _
n = n + 1: ReDim Preserve rm_List(1 To n): rm_List(n) = ds.ShareName
'sinon
nom = ds.ShareName
Next
ActiveSheet.Range("A1").Select
For i = 1 To n
ActiveCell.Value = rm_List(i)
ActiveCell.Offset(1, 0).Select
Next i
End Sub |
Sub ListDrives()
Dim rm_List(), Lecteur, ds As Object, n As Byte, i As Byte
' Pulisco i dati precedenti sulla colonna A
Range("a1:a" & Cells(Rows.Count, 1).End(xlUp).Row).ClearContents
Set Lecteur = CreateObject("Scripting.FileSystemObject")
ReDim rm_List(1 To Lecteur.drives.Count, 2)
On Error Resume Next
For Each ds In Lecteur.drives
n = n + 1: rm_List(n, 1) = ds.Path: rm_List(n, 2) = ds.VolumeName
Next
On Error GoTo 0
For i = 1 To UBound(rm_List)
Cells(i, 1).Value = rm_List(i, 1) & " " & rm_List(i, 2)
Next
End Sub
|
Set Lecteur = CreateObject("Scripting.FileSystemObject")
