John Schultz was telling us: John Schultz nous racontait que :
[Quoted Text] > I can't get my userform to show. I tried "NameOfForm.Show", but it > does not recognize the object. What am I missing?
Show us the full Sub you are using to call the userform. Do you have any code in the initialize or Activate events of the userform?
> I am trying to create a drop-down in a userform that lists all the > subfolders in a particular folder that I specify. Is there a > collection for subfolders? Where do I access a list of subfolders?
Do you have any code for this yet?
In any case, here is an example of one of the many ways you could do this. This example assumes that you have a userform named "frmSubFolders" which contains a combobox named "cmbSubFolder" and a command button that only has the following code: Me.Hide
'_______________________________________ Option Explicit '_______________________________________ Sub Main()
Dim frmMain As frmSubFolders Dim colList As Collection Dim i As Long
Set colList = colSubFolder Set frmMain = New frmSubFolders
With frmMain For i = 1 To colList.Count .cmbSubFolder.AddItem colList(i) Next .Show End With
Unload frmMain
Set frmMain = Nothing
End Sub '_______________________________________
'_______________________________________ Function colSubFolder() As Collection
Dim strPath As String Dim strSubFolder As String
Set colSubFolder = New Collection
strPath = "C:\Clients\"
strSubFolder = Dir(strPath, vbDirectory) Do While strSubFolder <> "" 'Ignore the current folder and parent folder If strSubFolder <> "." And strSubFolder <> ".." Then 'Make sure strSubFolder is a folder. If (GetAttr(strPath & strSubFolder) And vbDirectory) _ = vbDirectory Then 'Add to collection colSubFolder.Add strSubFolder End If End If 'Get next folder strSubFolder = Dir Loop
End Function '_______________________________________
--
Salut! _______________________________________ Jean-Guy Marcil - Word MVP jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO Word MVP site: http://www.word.mvps.org
|