List Box

G

George

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
 
J

Joel

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
 
G

George

Joel - I am using Office 2007 but I don't think that makes a different,
anyway I tried what you gave me and nothing happens.

The List Box in Sheet 1 shows the items I have loaded in sheet 2 and changes
when I change the items in Sheet 2 so that part is working. But when I click
on any on the items in the List Box on Sheet 1 it does no open any of the
items. I loaded the code you gave me by right clicking on the sheet tab and
scrolled up to View Code - is that right ?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top