Control Name

R

Richard

Can someone please tell me the name of the control that allows you to browse
the directories and folders. I would like to be able to browse to an excel
file in "My Documents" to import. And second can I do this from my Import
spreadsheet macro?

Thanks
Richard
 
A

Albert D. Kallal

Richard said:
Can someone please tell me the name of the control that allows you to
browse
the directories and folders. I would like to be able to browse to an excel
file in "My Documents" to import. And second can I do this from my Import
spreadsheet macro?

Thanks
Richard



In 2002 and later, you can place a button on a form, and the code behind
that button can be:

Dim f As FileDialog

Set f = Application.FileDialog(msoFileDialogFilePicker)
f.Filters.Clear
f.Filters.Add "Excel", "*.xls", 1
f.Show

DoCmd.TransferSpreadsheet acImport, , "myTable", f.SelectedItems(1)


In the above, you have to change "myTable" to the name of the table you want
the data to go into...

I not 100%, but the FileDialog feature might have only been added to access
2003 and later. So,if you have a earlier version...there is other code
possibilities, but the above is the least amount of code.
 
R

Richard

Thank you Albert

Albert D. Kallal said:
In 2002 and later, you can place a button on a form, and the code behind
that button can be:

Dim f As FileDialog

Set f = Application.FileDialog(msoFileDialogFilePicker)
f.Filters.Clear
f.Filters.Add "Excel", "*.xls", 1
f.Show

DoCmd.TransferSpreadsheet acImport, , "myTable", f.SelectedItems(1)


In the above, you have to change "myTable" to the name of the table you want
the data to go into...

I not 100%, but the FileDialog feature might have only been added to access
2003 and later. So,if you have a earlier version...there is other code
possibilities, but the above is the least amount of code.
 
A

Alicia Susana Satas

Richard said:
Can someone please tell me the name of the control that allows you to
browse
the directories and folders. I would like to be able to browse to an excel
file in "My Documents" to import. And second can I do this from my Import
spreadsheet macro?

Thanks
Richard
 

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