Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Returning a file - path with vba-code

0 views
Skip to first unread message

Jan T.

unread,
Dec 4, 2009, 4:17:50 PM12/4/09
to
Hi.
I have Access 2000 and Word 2007 home edition and I want to open or
browse for a file with using a dialog to return the file path.

In Excel, I have used;
strFilePath = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
or....
Function File_2_Open() As String
Dim strVar As Variant
On Error Resume Next
strVar = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
Workbooks.Open strVar
' deal with it... your code here...
File_2_Open = strVar
End Function

or...


Tom van Stiphout

unread,
Dec 6, 2009, 6:50:49 PM12/6/09
to
On Fri, 4 Dec 2009 22:17:50 +0100, "Jan T." <noreply> wrote:

Check this out:
http://www.mvps.org/access/api/api0001.htm
and bookmark that site!

-Tom.
Microsoft Access MVP

Albert D. Kallal

unread,
Dec 12, 2009, 4:26:24 AM12/12/09
to

I access 2003 and later, you can use:

Dim f As FileDialog
Set f = Application.FileDialog(msoFileDialogFilePicker)
f.Show
MsgBox "file choose was " & f.SelectedItems(1)

above needs: Microsoft Object 11.0 Object library

If you remove the reference to the 11.0 object library, then the following
code will work without any references:


Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
f.Show

MsgBox "file choosen = " & f.SelectedItems.Count

Note that above also works in runtime. So:

Dim f As FileDialog

Set f = Application.FileDialog(msoFileDialogFilePicker)
f.Filters.Add "Excel Files (*.xls)", "*.xls"
f.Show
MsgBox "file choose was " & f.SelectedItems(1)

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOO...@msn.com


0 new messages