25 May 12 16:49
All I'm trying to do is get an 'open file' dialog to work. In XP it was the easiest thing in the world but in Windows 7 (64 bit) the old dialogs don't exist. From some googling I've found this can supposedly be done with BrowseForFolder which has an option to include browsing for files.
This code should work from what I understand. It successfully opens the dialog and starts browsing in the correct folder. However, when I select the file I want and click 'OK' it returns an "unspecified error - 80004005" on the 'Set oFolder' line. From what I can find, that is often a permissions related error, but I am an admin on the machine and the owner of the directory I'm browsing in. Any thoughts what I'm missing here or will this just not do what I want?
Const MY_DOCUMENTS = &H5&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_DOCUMENTS)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
strPath = strPath & "\BlackBoardBatch"
Const INCLUDEFILES = &H4000 ' Browsing for Everything
Const strTitle = "Select a merge_data file... "
vOptions = INCLUDEFILES
Set oFolder = objShell.BrowseForFolder(&H0, strTitle, vOptions, strPath)
If (oFolder Is Nothing) then 'clicked cancel
ElseIf (UCase(TypeName(oFolder)) = "FOLDER") Then
sResult = oFolder.ParentFolder.ParseName(oFolder.Title).Path
A good write-up on this method can be found Here
Any suggestions would be appreciated.