Kevin-
Look at the function GetFileName in the modStartup module. You would need to modify that to change the title to "Locate Excel Spreadsheet" and the extension to "xls" or "xlsx". Pass the function a string argument containing "*.xls" or "*.xlsx" into which it will return the full path of the if the user selects a file. The function returns True when a file has been selected. Then use the returned value in a TransferSpreadsheet.John Viescas, AuthorMicrosoft Access 2010 Inside OutMicrosoft Access 2007 Inside OutMicrosoft Access 2003 Inside OutBuilding Microsoft Access ApplicationsSQL Queries for Mere Mortals(Paris, France)
On Dec 16, 2015, at 8:12 AM, 'zhaoliqingoffice@163.com' zhaoliqingoffice@163.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:John-I just import all the files from StartupExample.zip. Would you please give an example on how to embed it in a TransferSpreadsheet commant to imprt the file? Thanks.Best Regards,Kevin
Date: 2015-12-15 17:41Subject: Re: [MS_AccessPros] Import data from excel to MSAcceasKevin-
You must make a call to the file system or Windows to open a file dialog where the user can select the file. There's some sample code doing it with a call to Windows in StartupExample.zip that I recently uploaded to Files / Modules and Classes. After you have the file name, embed it in a TransferSpreadsheet command to import the file.John Viescas, AuthorMicrosoft Access 2010 Inside OutMicrosoft Access 2007 Inside OutMicrosoft Access 2003 Inside OutBuilding Microsoft Access ApplicationsSQL Queries for Mere Mortals(Paris, France)
On Dec 15, 2015, at 3:40 AM, 'zhaoliqingoffice@163.com' zhaoliqingoffice@163.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:Siguard,Actually, I want to achieve this: when clicking on a button, a pop up window will show from where I want to import, then follow the steps to complete the importing procedure. What you suggest is that , I have to import something previously and save the name. Which is not quite applicable in this situation. Is it possible to achieve what I expected? Thanks in advance.Best Regards,Kevin
Date: 2015-12-15 09:48Subject: Re: [MS_AccessPros] Import data from excel to MSAcceasAfter you manually go through the import and give it a name, yes - this worked for me.
I was importing from a text file but I would expect this process to work to import from Excel as well.
Sigurd
On 12/14/2015 8:33 PM, zhaoliqingoffice zhaoliqingoffice@163.com [MS_Access_Professionals] wrote:
Sigurd-
Thanks a lot. So the last code line can be used in VBA to import excel, right? I am going to try at office today. Thanks again.
Best Regards,
Kevin
发自我的小米手机在 "Sigurd Andersen sigurd@solbakkn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>,2015年12月15日 上午9:21写道:
I have just dealt with this today.
Both the method I was using and the one that worked are based on using an import specification.
(by "import specification" I mean going to External Data, Import (various types of files possible).
After going through various steps, you're given the chance to save the specification (based on the
steps just taken) with a name. Remember this name.
In an application developed with an earlier version of Access, I was using
CurrentProject.ImportExportSpecifications("import-spec-name").Execute (False)
Wouldn't work with a newly defined import. With a little research I found
DoCmd.RunSavedImportExport ("import-spec-name")
which worked just fine for me.
Sigurd Andersen
On 12/14/2015 7:04 PM, zhaoliqingoffice zhaoliqingoffice@163.com [MS_Access_Professionals] wrote:
Dear All,
What is the code for importing data from excel to MS Access? Thanks.
Best Regards,
Kevin
Posted by: zhaoliqingoffice <zhaoliqingoffice@163.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (10) |
Tidak ada komentar:
Posting Komentar