Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Utilisation de WMI dans les macros

1 réponse
Avatar
Toto
Bonjour

Est-il possible d'utiliser les objets WMI Win32_Directory et CIM_Datafile dans une macro Excel

Merc
Toto

1 réponse

Avatar
Alain CROS
Bonjour

CIM_Datafile ?
Pour WMI Win32_Directory, attention, ça dure un certain temps.

Sub Win32_Directory()
Dim ObjWMIService As Object, ColItems As Object
Dim StrComputer$, ObjItem As Object, I&, J&
Application.ScreenUpdating = False
On Error Resume Next
StrComputer = "."
Set ObjWMIService = GetObject("winmgmts:" & StrComputer & "rootcimv2")
Set ColItems = ObjWMIService.ExecQuery("Select * from Win32_Directory", , 48)
[A1] = "AccessMask"
[B1] = "Archive"
[C1] = "Caption"
[D1] = "Compressed"
[E1] = "CompressionMethod"
[F1] = "CreationClassName"
[G1] = "CreationDate"
[H1] = "CSCreationClassName"
[I1] = "CSName"
[J1] = "Description"
[K1] = "Drive"
[L1] = "EightDotThreeFileName"
[M1] = "Encrypted"
[N1] = "EncryptionMethod"
[O1] = "Extension"
[P1] = "FileName"
[Q1] = "FileSize"
[R1] = "FileType"
[S1] = "FSCreationClassName"
[T1] = "FSName"
[U1] = "Hidden"
[V1] = "InstallDate"
[W1] = "InUseCount"
[X1] = "LastAccessed"
[Y1] = "LastModified"
[Z1] = "Name"
[AA1] = "Path"
[AB1] = "Readable"
[AC1] = "Status"
[AD1] = "System"
[AE1] = "Writeable"
I = 2&: J = 1&
For Each ObjItem In ColItems
With ObjItem
Cells(I, J) = .AccessMask: J = J + 1
Cells(I, J) = .Archive: J = J + 1
Cells(I, J) = .Caption: J = J + 1
Cells(I, J) = .Compressed: J = J + 1
Cells(I, J) = .CompressionMethod: J = J + 1
Cells(I, J) = .CreationClassName: J = J + 1
Cells(I, J) = .CreationDate: J = J + 1
Cells(I, J) = .CSCreationClassName: J = J + 1
Cells(I, J) = .CSName: J = J + 1
Cells(I, J) = .Description: J = J + 1
Cells(I, J) = .Drive: J = J + 1
Cells(I, J) = .EightDotThreeFileName: J = J + 1
Cells(I, J) = .Encrypted: J = J + 1
Cells(I, J) = .EncryptionMethod: J = J + 1
Cells(I, J) = .Extension: J = J + 1
Cells(I, J) = .FileName: J = J + 1
Cells(I, J) = .FileSize: J = J + 1
Cells(I, J) = .FileType: J = J + 1
Cells(I, J) = .FSCreationClassName: J = J + 1
Cells(I, J) = .FSName: J = J + 1
Cells(I, J) = .Hidden: J = J + 1
Cells(I, J) = .InstallDate: J = J + 1
Cells(I, J) = .InUseCount: J = J + 1
Cells(I, J) = .LastAccessed: J = J + 1
Cells(I, J) = .LastModified: J = J + 1
Cells(I, J) = .Name: J = J + 1
Cells(I, J) = .Path: J = J + 1
Cells(I, J) = .Readable: J = J + 1
Cells(I, J) = .Status: J = J + 1
Cells(I, J) = .System: J = J + 1
Cells(I, J) = .Writeable: J = 1: I = I + 1
End With
Next ObjItem
On Error GoTo 0
For I = 1& To UsedRange.Columns.Count
Columns(I).AutoFit
Next I
Application.ScreenUpdating = True
End Sub

Alain CROS

"Toto" a écrit dans le message de news:
Bonjour

Est-il possible d'utiliser les objets WMI Win32_Directory et CIM_Datafile dans une macro Excell

Merci
Toto