double_click event

K

kerry

Hi

I am trying to create a simple insert file procedure.
Based on a list of files in a directory I would like to be
able to double click a file in a list box and the file be
inserted into my current document (I know this is similar
to the current insert file procedure but I need to make
the box simpler and insert multiple files).

Currently, I have a userform with a list box displaying
all the files in a selected directory (see code below). I
have tried to add a double click event to the list box but
it doesn't seem to recognise what file I selected - any
ideas??

Thanks very much for your time.

Kerry
--------

Private Sub UserForm_Activate()

Dim MyFile As String
Dim Counter As Long

Dim DirectoryListArray() As String
ReDim DirectoryListArray(1000)

'Loop through all the files in the directory
MyFile = Dir$("C:\my Documents\*.*")
Do While MyFile <> ""
DirectoryListArray(Counter) = MyFile
MyFile = Dir$
Counter = Counter + 1
Loop

ReDim Preserve DirectoryListArray(Counter - 1)

For Counter = 0 To UBound(DirectoryListArray)
'Debug.Print writes the results to the Immediate
window (press Ctrl + G to view it)'
Debug.Print DirectoryListArray(Counter)
Next Counter

'populate the Listbox
ListBox1.List = DirectoryListArray
End Sub
 

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