Thread: List Box
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default List Box

This code is intended to run with Listbox1. The best way of getting this
code to work is to do the following

1) Enter Design Mode by opening the toolbar Control Toolbox

from menu View - Toolbars - control toolbox

2) Click on Triangle to enter/exit design mode. this is a toogle button.

3) When in Design mode double click listbox which will create the boiler
plate for the listbox. Insert the second a third lines of the code below.
chang ethe list box name in line 2 to match the name of the listbox in line 1.

4) Go back to worksheet and right click listbox. Select properties and
change listfillrange to the following

Sheet2!A1:A20 or the sheet and range where the filenames are located

5) Click on triangle in toolbar again to exit design mode. Clicking an item
in the listbox should now open the file.


Private Sub ListBox1_Click()
FName = ActiveSheet.ListBox1.Value 'change listbox name to match header.
Workbooks.Open Filename:=FName

End Sub


"George" wrote:

I created a list box so I can click on the item in the drop down and have it
open documents on our LAN and or C-Drive. How do I setup the items in my list
box to open these items ? As of now in my workbook I have one sheet just for
the list box and one sheet to list all the documents.

Thanks