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

Invoking File Menu programatically 2

Status
Not open for further replies.

blacktorncoat

Programmer
Dec 2, 2004
32
IL
Hello,
Can anyone point out to me how to invoke the file menu programatically, to return a string of file name+directory?

Thanks,
Yaron.
 
With some versions of ms-access you may play with the FileDialog object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for replying,PHV, but I still can't seem to get it to work.. most examples I see on the web are using

" Dim FD as Office.FileDialog"

or

"Dim FD as FileDialog"

both result in "User-defined type not defined."
I am using Microsoft Access 10 Object Library.

Anyone knows how to get it done?
Thanks,
Y.

 
You should reference the Microsoft Office 10 Object Library too.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi

You could use the following function :

' need to set a reference to Microsoft Office 10.0 Object Library

Function MyFile()
Dim FileDlg As FileDialog

MyFile = ""
Set FileDlg = Application.FileDialog(msoFileDialogFilePicker)

With FileDlg
.Title = "My find dialog"
.AllowMultiSelect = False
.Filters.Add "Word Documents", "*.doc"
.InitialFileName = "C:\"
.Show
If .SelectedItems.Count > 0 Then
MyFile = .SelectedItems(1)
End If
End With

Set FileDlg = Nothing

End Function


Obviously you could change the code to show more files or even parameterise which files to show etc..

Code to use this would look like

dim SelectedFile as string

SelectedFile = myfile()
if len(selectedfile) > 0 then
' we have a filename
end if





Hope this helps!

Regards

BuilderSpec
 
Thanks PHV and BuilderSpec !
I confused Microsoft Access Object Library with Microsoft Office Object Library. It works fine now.

Y.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top