File Dialog

E

Eli the Iceman

greetings,

I am tryihg to get FileDialog to work, I know about the ASP fie, but I
prefer to use the File Dialog as all I need is to paste a folder link in a
table via a form control. I got Filedialog to work, but am running into an
issue. My control on the form is a hyperlink, so if you paste the file path
or type it in, you can then click on the link and it will open a new window
of the path. However, when I select the path via FileDialog, it still shows
as a link, but will not follow it. Any suggestions? Code is below: Thanks,

Public Function PickFolder() As String

Dim fd As FileDialog

Set fd = Application.FileDialog(msoFileDialogFolderPicker)

Dim vrtSelectedItem As Variant

With fd

If .Show = -1 Then

For Each vrtSelectedItem In .SelectedItems

Screen.ActiveControl = vrtSelectedItem

Next vrtSelectedItem
Else
End If
End With

Set fd = Nothing

End Function
 
P

pietlinden

greetings,

I am tryihg to get FileDialog to work, I know about the ASP fie, but I
prefer to use the File Dialog as all I need is to paste a folder link in a
table via a form control.  I got Filedialog to work, but am running into an
issue.  My control on the form is a hyperlink, so if you paste the filepath
or type it in, you can then click on the link and it will open a new window
of the path.  However, when I select the path via FileDialog, it still shows
as a link, but will not follow it.  Any suggestions?

1. store the path in your table as a text field.
2. use the BrowseFolder API at Access Web - use either a button or the
double-click event of the control.
 
E

Eli the Iceman

I can't get it to work, I made a module with the following code, but I get an
error of can't find it. When I place the code on the form it works, but it
does not store the path on the control. The original code I made does
capture the path and place it on the control, but the link is dead. Will
API, if configured right, work by being placed inside the text box and then
be hyperlinked when clicked on?

Thanks,
'************** Code Start **************
'This code was originally written by Terry Kreft.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code courtesy of
'Terry Kreft

Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long

Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
As Long

Private Const BIF_RETURNONLYFSDIRS = &H1
Public Function BrowseFolder(szDialogTitle As String) As String
Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer

With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
End With

dwIList = SHBrowseForFolder(bi)
szPath = Space$(512)
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)

If X Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Else
BrowseFolder = vbNullString
End If
End Function
'*********** Code End *****************
 
E

Eli the Iceman

I got the field to be populated, but again, it looses the hyperlink when
clicked on. I must be doing something wrong.
 
P

pietlinden

I got the field to be populated, but again, it looses the hyperlink when
clicked on.  I must be doing something wrong.

me too. Only way I could get it to work (might be my own stupidity)
is to use Application.FollowHyperlink on the textbox's DblClick
event. Irritating...
 
P

pietlinden

Thank you very much, that did it, weird, but it worked.  Thanks again......

That's what I thought. I would have expected it to work in a more
intuitive way.
 

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