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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.)
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
(Select the file, ...then select the sheet.)
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
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!"