Link to home
Start Free TrialLog in
Avatar of Jess31
Jess31

asked on

Dialog for user to select a worksheet?

In Access VBA I use Application.FileDialog to select a file but how can I select a workbook and then the specific worksheet?
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

your question is so vague.
what do you intend to do after selecting the excel file?
 - open the excel file than select the specific worksheet
- do you want to import the content of the worksheet?
   docmd.transferspreadsheet acimport, "tablename", strexcelfile, true, "NAMEOFSHEET!"
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I use a technique similar to that used by Rgonzo1971
On the other side of things, ...Notice that here you are simply simulating the Access built in Import wizard
(Select the file, ...then select the sheet.)
User generated imageUser generated imageUser generated image
So instead of going through all this code, ...why not just use the wizard?:

The advantages are:
1. Only one line of code is needed:
    DoCmd.RunCommand acCmdImportAttachExcel
2. With the wizard you can select things like:
a. Append, of Import, or Link
b. First Row contains field names
c. You can rename fields
d. you can change datatypes
e. Let Access add a primary Key
f. the ability to move back and forth through the wizard
...etc

Why reinvent the wheel?

JeffCoachman