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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating Combo Box with Files From Folders

Status
Not open for further replies.

CharlieT302

Instructor
Mar 17, 2005
406
0
0
US
Hello,

I would like to have my combo box display a list of files from a folder that resides on a SharePoint drive. I have done this with files residing in network folders without a problem, but apparently the combo box is not reading the SharePoint site in the same manner.

Here is my current code (using the OnLoad event)

Note:
Image_Select = Combo Box
StrFolder = the field containing the path (the URL, in this case -
List_files: 'List Files - Update List
Me.Image_Select.RowSource = ""

Dim StrFolder As String
Dim StrPath As String
Dim PictureSubfolder As String

StrFolder = DLookup("Parent_Pic_Path", "tbl_Picture_Paths") 'assigns the root folder
StrPath = StrFolder
PictureList = Dir("StrPath", vbArchive)

Do While Len(PictureSubfolder) > 0

' Ignore directories
If (PictureList <> ".") And (PictureList <> "..") Then
Image_Select.AddItem PictureList
End If
PictureSubfolder = Dir
Loop

My only other option is to use a file dialog box, which I am O.K. with except that the above allows me to point to the location of the images without requiring any navigation.

All help is appreciated.
 
Code:
PictureList = Dir([highlight #FCE94F]"StrPath"[/highlight], vbArchive)

You have used a string, not the variable, perhaps this is the problem?

Try removing the quotes, so you are using the variable value instead of a string value.





"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
I have tried this with and without quotes. The issue seems to stem around the Dir() command not being compatible with an: HTTP:/ address, which is what is referenced by: StrPath (this is a SharePoint site). So, I suppose the question is: what is the technique used to reference the HTTP location.

Note: I can use code to open a File dialog box (Set fDialog = Application.FileDialog(msoFileDialogFilePicker)), which will reference the SharePoint library. When open, I can select a single or multiple files from SharePoint. I can then populate a text box or even a list box with the selected files. This is obviously a silly way of populating a listbox, but is shows that it can be done.

This seems like it should be easy. Ideas?
 
Since you can get - using File dialog box - files "from SharePoint. I can then populate a text box or even a list box with the selected files", what do you get in your text box / list box?

Is it something like:[tt]
p:\Folder\SomeFile.xyz
p:\OtherForler\abc.exe[/tt]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Alright, here is what is happening.

Using the code originally specified, I can populate a list box with filenames from a given folder on a local or network drive. When I attempt a similar technique specifying a SharePoint library, the listbox fails to populate. I will also receive the error code: 52 Bad filename or number.

Putting in quotes around Strpath (PictureList = Dir("StrPath", vbArchive) ), alleviated the error code but the listbox remains blank. So, basically, the code works with local drives but not SharePoint. My only point by mentioning the File Dialog Box, is that I find it interesting that it will connect to SharePoint. However, I really need to use a listbox if at all possible.

All I am asking is whether anyone knows how to populate a listbox using a SharePoint file list. It's been frustrating.

 
Would this help? it is probably Excel, but it may work in Access...

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top