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

File picker dialog box code

Status
Not open for further replies.

sillysod

Technical User
Jan 6, 2004
300
0
0
GB
this is starting to drive me crazy, VBA doesnt seem to like the .filter.add line code i have and i ant figure out why.


Dim dlgOpen As FileDialog
Dim strFileName As String

Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)



With dlgOpen

.InitialFileName = "C:\"
.Title = "Import Scanned Image"
.Filters.Add "Text Files (*.txt)", "*.TXT;*.RTF "
.Filters.Add "Pictures (*.jpg)", "*.JPG;*.JPEG;*.bmp"


End With

dlgOpen.Show


If dlgOpen.SelectedItems.count > 0 Then 'If an item has been selected then do something with it
strFileName = dlgOpen.SelectedItems(1) 'Save the selected item in variable



End If
txtPathName.SetFocus

txtPathName.Text = strFileName
 
Oh and another thing, how to I pull the image i will be linking too on a form? this value will be stored in a text field of a table, and the image box seems to only allow me to define the pictures filepath at design time
 
I think it may have something to do with your syntax. It looks like you are missing a quotation mark...below is the line I use and it works fine.

.Filters.Add "Excel", "*.xls"

Hope that helps.

Rocky
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top