FileDialog property

boomerang boi

Registered User.
Local time
Today, 20:00
Joined
Apr 14, 2008
Messages
16
I'm having some problems with this code

Code:
Private Sub AddPicture_Click()

    getFileName
    
End Sub
 
Sub getFileName()
    Dim fileName As String
    Dim result As Integer
    
    With Application.FileDialog([B]msoFileDialogFilePicker[/B])
   
        .TITLE = "Select Employee Picture"
        .Filters.Add "All Files", "*.*"
        .Filters.Add "JPEGs", "*.jpg"
        .Filters.Add "Bitmaps", "*.bmp"
        .Filters.Add "GIFs", "*.gif"
        .FilterIndex = 3
        .AllowMultiSelect = False
        .InitialFileName = CurrentProject.path
        .Show
        If (result <> 0) Then
            fileName = Trim(.SelectedItems.Item(1))
            Me![ImagePath].Visible = True
            Me![ImagePath].SetFocus
            Me![ImagePath].Text = fileName
            Me![FirstName].SetFocus
            Me![ImagePath].Visible = False
        End If
    End With
End Sub

I always get a variable not defined error when I execute this. The texts in the bold font is the one which the error occurs. Is there something wrong with the code?
 
just a quick comment here. I wrote a line in the editor with the extension of filedialog on "application", and when I tried to specify the type, it gave me an error saying that there was no reference to the appropriate library. I had to manually add this reference.

Just a piece of knowledge for you i guess....
 
uhmm, how can I add a reference?

Thanks.
 
From the menu Tools | References...
 
You need to add a reference to the Microsoft Office x.x Object Library (where x.x) is the version number.
 

Users who are viewing this thread

Back
Top Bottom