file dialog in access 2007

  • Thread starter Thread starter stumpy
  • Start date Start date
S

stumpy

the following code worked in office xp but i cannot seem to get it to work in
access 2007
Any help would be appreciated

Regards Rob.

Sub getFileName()

Dim fileName As String
Dim result As Integer

With Application.FileDialog(MsoFileDialogOpen)

.Title = "Select Picture"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Images", "*.jpeg;*.jpg;*.bmp", 1
.Filters.Add "All Files", "*.*"
.InitialFileName = "C:\Users\Rob\My Pictures"
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))

Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![Exit].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub
 
stumpy said:
the following code worked in office xp but i cannot seem to get it to work
in
access 2007
Any help would be appreciated

Regards Rob.

Sub getFileName()

Dim fileName As String
Dim result As Integer

With Application.FileDialog(MsoFileDialogOpen)

.Title = "Select Picture"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Images", "*.jpeg;*.jpg;*.bmp", 1
.Filters.Add "All Files", "*.*"
.InitialFileName = "C:\Users\Rob\My Pictures"
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))

Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![Exit].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

Application.FileDialog has been removed from A2007 <shrug>

Here's a replacement:

http://www.smccall.demon.co.uk/MiscApi.htm#FileOpen
 
stumpy said:
the following code worked in office xp but i cannot seem to get it to work
in
access 2007
Any help would be appreciated

The followlign shoud work:

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

You can late bind if you wish:

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
 
I thought everyone always suggested to use the code (I think Ken Getz) wrote
it, I think it's on "the Access web". That way you don't need an extra
reference to something that might not be installed. There are versions for
single file selection and multiple file selection. I know I replaced my use
of filedialog with it.

Mark
RPT Software
http://www.rptsoftware.com

PS: If you can't find the code send me an email and I'll send it to you (use
my website for contact info).
 
Back
Top