LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default ActiveX Control Combo Box

This code is modified to use a ComboBox on a sheet from the Control Toolbox
and will identify the drive type.

Sub listDrv() 'Identifies drives and lists them in ComboBox
Dim fs, d, dc
Set fs = CreateObject("Scripting.FileSystemObject")
Set dc = fs.Drives
For Each d In dc
Select Case d.DriveType
Case 0: t = "Unknown"
Case 1: t = "Removable"
Case 2: t = "Fixed"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disk"
End Select
Sheets(1).ComboBox1.AddItem d & " \ " & "- " & t
Next
End Sub

"K" wrote:

On 16 Feb, 18:40, Kenneth Hobson
wrote:
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


Thanks guys your codes been very helpful.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 Form Control/ActiveX Control font difference Nikko963 Excel Discussion (Misc queries) 0 April 15th 09 04:21 PM
publish activeX combobox and other activeX control irene c Excel Programming 0 March 19th 07 07:19 AM
ActiveX combo box Carla[_4_] Excel Programming 2 July 22nd 04 10:00 PM
ActiveX Combo Andrew[_37_] Excel Programming 0 May 5th 04 06:11 PM
Combo Box (ActiveX) Dovid Excel Programming 2 March 2nd 04 07:32 PM


All times are GMT +1. The time now is 08:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"