Creating Listbox From Array, and using it

P

PatK

I have some code (below) that asks a user to select an Excel file (a lot of
the code is in other subroutines/functions not shown, but they work fine). I
then look at the file and build a small array of all possible worksheet tabs
within the excel file. I want the user to "pick" one of these files, and I
will pass the value to the next step in my code (namely, to link an excel
worksheet to my access DB).

The file selection process is working fine, and the debug lines are
outputing just what I would expect from the file I have selected, namely:
WSArray(0): Sheet1
WSArray(1): Sheet2
WSArray(2): Sheet3

Now comes the part where I want to pop up a form (I assume it needs to be a
form) to allow the user the chance to select the excel file/worksheet
combination, to link.

----------------------
Sub MainLine()
Dim sFname As String 'String to store selected file
Dim WSArray() As String 'Array of worksheet names
Dim i As Integer
sFname = GetXLSFile()

WSArray() = GetWSName(sFname)
For i = 0 To UBound(WSArray)
Debug.Print "WSArray(" & i & "): " & WSArray(i)
Next i

PopupUserWSChoicebox(WSArray()) ' this is pretend code, this line, that I
Need _ help on.
End Sub
--------------------------
Now, I realize this code does not say much, but my key questions are:
- Do I have to create a form, to present a listbox?
- If so, being a vba/form newbie, would someone give me a pointer to a type
to force a pop-up box from which a user would have a listbox to choose the
worsheet desired to link?

I am not really looking for any code (altho samples are GREAT), but rather,
a suggested "best practice" for this.

Once I have the worksheet Linked to the DB, I will then process it like a
records set, and then unlink it.

SUggestions/IDeas?

Patk
 

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