Access 2000 - FIle Open Dialogue

P

Patrick

I am using Access 2000 and am trying to a File Open Dialogue running....and
getting compile error "Method not found". I have added a library reference
for "Microsoft Office 11.0 object Library". If I type "Application.",
Intellisense does not show FIleDialogue as a Method. (Is it possible I might
be better off using the Windows SDK equivalent? HOw do I find out more about
that?)

The code I am using to start with is a well known starting point but will
not compile. I suspect it might not work with Access 2000......

Private Sub cmdOpenDialogue_DblClick(Cancel As Integer)
'Declare a variable as a FileDialog object.
Dim fd As Office.FileDialog
Dim app As Application

'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)


'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant

'Use a With...End With block to reference the FileDialog object.
With fd

'Use the Show method to display the File Picker dialog box
'The user pressed the action button.
If .Show = -1 Then

'Step through the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems

'vrtSelectedItem contains the path of each selected item.
'Here use any file I/O functions you want on the path.
'This example simply displays the path in a message box.
MsgBox "The path is: " & vrtSelectedItem

Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With

'Set the object variable to Nothing.
Set fd = Nothing


End Sub
 
P

Patrick

Many thanks.

This takes me back 6 years and several versions !!! Because I once bought
Ken Getz's book and did this back in 1999. This time round - I have his book
on Access 2002 - but at work its Access 2000 (+ Office XP) because we are
behind the times. I then find out his sugggestions in his latest book won't
work and I have thrown the 97 one away.
 
D

Dirk Goldgar

Patrick said:
I am using Access 2000 and am trying to a File Open Dialogue
running....and getting compile error "Method not found". I have
added a library reference for "Microsoft Office 11.0 object Library".
If I type "Application.", Intellisense does not show FIleDialogue as
a Method. (Is it possible I might be better off using the Windows SDK
equivalent? HOw do I find out more about that?)

The code I am using to start with is a well known starting point but
will not compile. I suspect it might not work with Access 2000......

The FileDialog property wasn't added to Access until Office 2002, so
that won't work. If you want to be version-independent, use the API
call that Klatuu pointed you to.
 
L

Larry Linson

Patrick said:
Many thanks.

This takes me back 6 years and several versions !!! Because I once bought
Ken Getz's book and did this back in 1999. This time round - I have his
book
on Access 2002 - but at work its Access 2000 (+ Office XP) because we are
behind the times. I then find out his sugggestions in his latest book
won't
work and I have thrown the 97 one away.

If you can get a (used or new) copy, and some have been available cheap on
the auction sites and through sellers of 'remaindered books', remember
"Never throw away a copy of Getz' book!" I have a copy of each edition of
the Developer Handbook and, had I been a user of his Access Cookbook, would
have kept those, too.

Larry Linson
Microsoft Access MVP
 

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