Option Explicit
'declares to check combo
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const CB_FINDSTRING = &H14C
Private Const CB_FINDSTRINGEXACT = &H158
Private Sub FillCombo()
Dim fso As FileSystemObject
Set fso = New FileSystemObject
Dim fldr As Folder
Dim fle As File
'clear contents of combo
Combo1.Clear
'get the folder
Set fldr = fso.GetFolder(File1.Path)
'loop thru files
For Each fle In fldr.Files
Dim cbi As Integer
'test the extension against the combo
cbi = SendMessage(Combo1.hWnd, CB_FINDSTRINGEXACT, 0, ByVal fso.GetExtensionName(fle.Name))
If cbi = -1 Then
'it is a new extension so add it
Combo1.AddItem fso.GetExtensionName(fle.Name)
End If
Next
Set fldr = Nothing
Set fle = Nothing
Set fso = Nothing
End Sub
Private Sub Combo1_Click()
'change pattern to selected
If Combo1.Text <> "" Then
File1.Pattern = "*." & Combo1.Text
End If
End Sub
Private Sub File1_PathChange()
'path changed refill combo
FillCombo
End Sub
Private Sub Form_Load()
'fill combo
FillCombo
End Sub