General discussion

Locked

Access2K - Browse to return Path

By RichTee ·
I have a common dialog box control on a form in Access 2000. There are two visible controls on the form: a command button named 'cmdBrowse' and a text box control named 'txtPATH'.

I want to browse for a file, select it, and have ONLY the PATH to the file returned to the text box control on the same form.

I do not want to open the file, I only want to bring back the PATH as the value in the 'txtPATH'.

For example: after selection, the returned value in 'txtPATH' would be: 'C:\MyDocuments\Project\Xyx.doc'

Any help will be appreciated. Thanks.

Rich

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Access2K - Browse to return Path

by sgt_shultz In reply to Access2K - Browse to retu ...

sounds like a little code is needed...here is some code i used long ago that displays folder list and opens the folder picked by the user...
first, the function....
=======================================
Function GetBrowseDirectory() As String
' Function GetBrowseDirectory(Owner As Form) As String
Dim bi As BROWSEINFO
Dim IDL As ITEMIDLIST
Dim r As Long
Dim pidl As Long
Dim tmpPath As String
Dim pos As Integer

' bi.hOwner = Owner.hwnd
bi.pidlRoot = 0&
bi.lpszTitle = "Choose a directory from the list."
bi.ulFlags = BIF_RETURNONLYFSDIRS
pidl = SHBrowseForFolder(bi)

tmpPath = Space$(512)
r = SHGetPathFromIDList(ByVal pidl, ByVal tmpPath)

If r Then
pos = InStr(tmpPath, Chr$(0))
tmpPath = Left(tmpPath, pos - 1)

If Right(tmpPath, 1) <> "\" Then tmpPath = tmpPath & "\"
GetBrowseDirectory = tmpPath
Else
GetBrowseDirectory = ""
End If


End Function

Collapse -

Access2K - Browse to return Path

by RichTee In reply to Access2K - Browse to retu ...

Poster rated this answer

Collapse -

Access2K - Browse to return Path

by sgt_shultz In reply to Access2K - Browse to retu ...

second, the code that calls the function..
================================
================
Dim MyFile As String
Dim MyDir As String
Dim fs
Dim i As Integer

Set fs = Application.FileSearch
With fs

' x = BrowseForFolder(10, "Select a folder")

'Now you will be able to call the Browse for folder dialog by using the following line of code from your program:


' myDir = GetBrowseDirectory(form1)
' myDir = GetBrowseDirectory(Application.ActiveDocument)
MyDir = GetBrowseDirectory()
'...where form1 is the form that will recieve all errormessages. myDir will hold the directory selected or "" (nothing) if selection is cancelled.

If MyDir = "" Then
MsgBox "No folder was selected"
Else
MsgBox "Folder Selected: " & MyDir
.LookIn = MyDir
.FileName = "*.doc"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Documents.Open FileName:=.FoundFiles(i), ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
MyFile = .FoundFiles(i)
MyFile = Left$(MyFile, (Len(MyFile)) - 3)
MyFile = MyFile & "html"
ActiveDocument.SaveAs FileName:=MyFile, FileFormat:= _
wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
' ActiveWindow.View.Type = wdWebView
ActiveDocument.Close
Next iElse
MsgBox "There were no .doc files found."
End If
End If
End With

End Sub
=============================

Collapse -

Access2K - Browse to return Path

by sgt_shultz In reply to Access2K - Browse to retu ...

the above code for word so maybe play in there with it, then try to translate to access...
third, the real help:
here are some resources that might help more (i am not a programmer tho i play one on tv):
www.experts-exchange.com
www.planet-source-code.com
www.visualbasicforum.com
good luck and hope you grind thru it...

Collapse -

Access2K - Browse to return Path

by RichTee In reply to Access2K - Browse to retu ...

Poster rated this answer

Collapse -

Access2K - Browse to return Path

by RichTee In reply to Access2K - Browse to retu ...

to sgt_shultz:

Thanks for your imput and suggestions for some sites to research. I went to www.planet-source-code.com and did some searching and got the code I needed. Thanks again.

Collapse -

Access2K - Browse to return Path

by RichTee In reply to Access2K - Browse to retu ...

This question was closed by the author

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums