View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Kenneth Hobson[_4_] Kenneth Hobson[_4_] is offline
external usenet poster
 
Posts: 10
Default ActiveX Control Combo Box

If you want to use Bernie's WMI method, here is an example. Notice the link
to a site that shows the properties for the object. I also commented some
other ways to tack on parts that you might want.

Private Sub ComboBox1_GotFocus()
'ComboBox1.List = DriveList
ComboBox1.List = GetDrivesByWMI
End Sub

Function GetDrivesByWMI() As Variant
'add, Tools References... Microsoft WMI Scripting Library
'http://pageofwords.com/blog/content/binary/TechEdTranscript.txt
Dim colDisks As SWbemObjectSet
Dim objDisk As SWbemObject
Dim myDisks
Dim i As Integer

Set colDisks = GetObject( _
"Winmgmts:").ExecQuery("Select * from Win32_LogicalDisk")

i = 0
ReDim myDisks(1 To colDisks.Count)
For Each objDisk In colDisks
i = i + 1
myDisks(i) = objDisk.deviceid
'myDisks(i) = objDisk.DeviceID & " - " & objDisk.Description
'myDisks(i) = objDisk.deviceid & " - " & objDisk.DriveType
'myDisks(i) = objDisk.deviceid & " - " & objDisk.VolumeName
Next objDisk
GetDrivesByWMI = myDisks
End Function