Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to show folders in listbox

Status
Not open for further replies.

Storyteller

Instructor
Apr 19, 1999
343
CA
Hello All,
I am trying to create a UserForm in Outlook that will display a network folder in a list box/combo box and when the user double clicks on the folder another list box/combo box displays the contents of the folder.

For example the user opens the form and the box displays "Fax", "Transmittals", "Contracts" (showing the folders from //public/Templates/). After the user double clicks on "Fax" the box displays "Cover - Letterhead", "Cover - No Letterhead" (showing //public/Templates/Cover - Letterhead.dot)

The reason is that if someone adds a new template to a folder it will automatically be added to the list of available templates.

The plan is to pass via code the contact name and appropriate information to the template. I already have the code to pass the information to the template. What I need is help in creating the listbox/combobox to show the folders and then the files within the folders.

Regards,
Michael Microsoft Office 2000 Master Instructor
Corel Certified Instructor WordPerfect 9
 
This one was hard for me...I ended up creating a seperate userform dialog and stealing code from a few different sources to get it to work. This didn't work right over a Novell network until I took all the spacing out of the path folders and files and added parenthesis to the pathing...why I don't know.


Private Sub UserForm_Initialize()


Dim strFileArray() As String
Dim strFFile As String
Dim intCount As Integer


'note the path and wildcard at the end, you'll need to
'change it to match your path and filetype.

strFFile = Dir("D:\Documents\Docs\Work\MinutesProject\TestFolder\DepartmentDocs\Dept7\*.doc")

'The loop below allows it to grab all the files it finds in '
intCount = 1

Do While strFFile <> &quot;&quot;
If strFFile <> &quot;.&quot; And strFFile <> &quot;..&quot; Then
ReDim Preserve strFileArray(intCount)
strFileArray(intCount) = strFFile
intCount = intCount + 1
strFFile = Dir()
End If
Loop

lstFiles.List() = strFileArray

End Sub

'standard cancel button stuff, unloads the dialog and goes back 'to the main userform I simply hid from view

Private Sub cmdCancel_Click()

frmopnex.Hide

Unload frmopnex

ctmntsfrm.Show

End Sub


Private Sub cmdOpen_Click()

'this code checks to make sure there are files to open in
'the folder I've specified.

If lstFiles.Value <> &quot;&quot; Then Documents.Open _
FileName:=(&quot;D:\\Documents\Docs\Work\MinutesProject\TestFolder\DepartmentDocs\Dept7\&quot;) & lstFiles.Value


'again, after the selection is made, it closes the dialog
'and goes back to the main userform I've created.


frmopnex.Hide

Unload frmopnex

ctmntsfrm.Show

End Sub






*************************************
In an Information Age, knowlege is no longer power. Knowing the difference between useful data and useless data, THAT'S Power! -Me
************************************
 
By the way, I had to toy with this to get it to work properly on different platforms. It's tricky, but it can be done.

*************************************
In an Information Age, knowlege is no longer power. Knowing the difference between useful data and useless data, THAT'S Power! -Me
************************************
 
Hello DeusEx,
Thank you for your suggestion. I will have to try it out and let you know how it works for me.

Regards,
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top