473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Import/export data & selecting file location

Hi

I'm using this code to import data from an excel spreadsheet:

DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "tblStudents", _
"\\Egusersrv\Staff - Shared Work\PE Teach & Report\Imported
Spreadsheets/ImportStudents.xls", True

Which works fine if the spreadsheet is always in the pre-defined
location. Ideally what I would prefer to do is have the user locate
the file themselves, with perhaps the system defaulting to a folder
initially when the dialogue window opens. I would also like to apply
the same process to an export procedure from Access into an Excel
template too. Grateful for any help.

regards

David
Jul 14 '08 #1
4 6221
Call the Windows FileOpen/Save dialog.

Details in:
Call Windows File Open/Save Dialog box
at:
http://www.mvps.org/access/api/api0001.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David" <de********@gmail.comwrote in message
news:12**********************************@m73g2000 hsh.googlegroups.com...
>
I'm using this code to import data from an excel spreadsheet:

DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "tblStudents", _
"\\Egusersrv\Staff - Shared Work\PE Teach & Report\Imported
Spreadsheets/ImportStudents.xls", True

Which works fine if the spreadsheet is always in the pre-defined
location. Ideally what I would prefer to do is have the user locate
the file themselves, with perhaps the system defaulting to a folder
initially when the dialogue window opens. I would also like to apply
the same process to an export procedure from Access into an Excel
template too. Grateful for any help.

regards

David
Jul 14 '08 #2
On 14 Jul, 14:48, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Call the Windows FileOpen/Save dialog.

Details in:
* * Call Windows File Open/Save Dialog box
at:
* *http://www.mvps.org/access/api/api0001.htm

--
Allen Browne - Microsoft MVP. *Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David" <deejayq...@gmail.comwrote in message

news:12**********************************@m73g2000 hsh.googlegroups.com...


I'm using this code to import data from an excel spreadsheet:
DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "tblStudents", _
"\\Egusersrv\Staff - Shared Work\PE Teach & Report\Imported
Spreadsheets/ImportStudents.xls", True
Which works fine if the spreadsheet is always in the pre-defined
location. *Ideally what I would prefer to do is have the user locate
the file themselves, with perhaps the system defaulting to a folder
initially when the dialogue window opens. *I would also like to apply
the same process to an export procedure from Access into an Excel
template too. *Grateful for any help.
regards
David- Hide quoted text -

- Show quoted text -
Hi- I really don't want to appear lazy but I have looked at that
already and it doesn't make much sense, sorry my programming skills
are basic and I can't see how I tailor the code I already have to the
great long routine listed there! Do I need to copy and paste it into
a module and then call the module in my form code, some how connecting
them together??
Jul 14 '08 #3
API calls can look frightening if you've not used them before. This is
largely copy'n'paste stuff through, and it really is worth your time to get
this to work. If you do much with Access, you will need the functionality
again soon.

1. In Access, open the code window (Ctrl+G.)

2. Choose New Module on the Insert menu.
Access opens a code window.

3. Copy everything from the webpage from the Code Start to the Code End
lines, and paste into your new module.

4. Save the module with a name such as Module1.

5. To ensure Access understands the code, choose Compile on the Debug menu.

6. To test it, open the Immediate Window (Ctrl+G), and enter:
? TestIt()

You can then adapt the 2 examples at the top of the page - i.e.
ahtAddFilterItem() and ahtAddFilterItem() - to suit your needs.

My experience is that this is the only reliable way to do this in Access.
Other approaches fail when you need a new file name, fail when you switch
versions, require extra libraries, fail on different versions of Windows, or
just don't work properly.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David" <de********@gmail.comwrote in message
news:e1**********************************@59g2000h sb.googlegroups.com...
On 14 Jul, 14:48, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Call the Windows FileOpen/Save dialog.

Details in:
Call Windows File Open/Save Dialog box
at:
http://www.mvps.org/access/api/api0001.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David" <deejayq...@gmail.comwrote in message

news:12**********************************@m73g2000 hsh.googlegroups.com...


I'm using this code to import data from an excel spreadsheet:
DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "tblStudents", _
"\\Egusersrv\Staff - Shared Work\PE Teach & Report\Imported
Spreadsheets/ImportStudents.xls", True
Which works fine if the spreadsheet is always in the pre-defined
location. Ideally what I would prefer to do is have the user locate
the file themselves, with perhaps the system defaulting to a folder
initially when the dialogue window opens. I would also like to apply
the same process to an export procedure from Access into an Excel
template too. Grateful for any help.
regards
David- Hide quoted text -

- Show quoted text -
Hi- I really don't want to appear lazy but I have looked at that
already and it doesn't make much sense, sorry my programming skills
are basic and I can't see how I tailor the code I already have to the
great long routine listed there! Do I need to copy and paste it into
a module and then call the module in my form code, some how connecting
them together??

Jul 14 '08 #4
On 14 Jul, 15:07, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
API calls can look frightening if you've not used them before. This is
largely copy'n'paste stuff through, and it really is worth your time to get
this to work. If you do much with Access, you will need the functionality
again soon.

1. In Access, open the code window (Ctrl+G.)

2. Choose New Module on the Insert menu.
Access opens a code window.

3. Copy everything from the webpage from the Code Start to the Code End
lines, and paste into your new module.

4. Save the module with a name such as Module1.

5. To ensure Access understands the code, choose Compile on the Debug menu.

6. To test it, open the Immediate Window (Ctrl+G), and enter:
* * ? TestIt()

You can then adapt the 2 examples at the top of the page - i.e.
ahtAddFilterItem() and ahtAddFilterItem() - to suit your needs.

My experience is that this is the only reliable way to do this in Access.
Other approaches fail when you need a new file name, fail when you switch
versions, require extra libraries, fail on different versions of Windows,or
just don't work properly.

--
Allen Browne - Microsoft MVP. *Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David" <deejayq...@gmail.comwrote in message

news:e1**********************************@59g2000h sb.googlegroups.com...
On 14 Jul, 14:48, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:


Call the Windows FileOpen/Save dialog.
Details in:
Call Windows File Open/Save Dialog box
at:
http://www.mvps.org/access/api/api0001.htm
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"David" <deejayq...@gmail.comwrote in message
news:12**********************************@m73g2000 hsh.googlegroups.com....
I'm using this code to import data from an excel spreadsheet:
DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, "tblStudents", _
"\\Egusersrv\Staff - Shared Work\PE Teach & Report\Imported
Spreadsheets/ImportStudents.xls", True
Which works fine if the spreadsheet is always in the pre-defined
location. Ideally what I would prefer to do is have the user locate
the file themselves, with perhaps the system defaulting to a folder
initially when the dialogue window opens. I would also like to apply
the same process to an export procedure from Access into an Excel
template too. Grateful for any help.
regards
David- Hide quoted text -
- Show quoted text -

Hi- I really don't want to appear lazy but I have looked at that
already and it doesn't make much sense, sorry my programming skills
are basic and I can't see how I tailor the code I already have to the
great long routine listed there! *Do I need to copy and paste it into
a module and then call the module in my form code, some how connecting
them together??- Hide quoted text -

- Show quoted text -
Allen, many thanks I will try this- I just needed the Dummies
introduction, which you have just given me!
Jul 14 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Benny | last post by:
Dear All, I am performing a data import on the SQL server. Due to fact that I use the excel file as a source. Some of cells in excel are actually empty, they become NULL fields after importing...
4
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
4
by: N. Graves | last post by:
Thanks for taking the time to read this note. I have a Access inventory collection tool that I have automated to build and Export to a CSV file. In the database I have several fields that are...
2
by: Siu | last post by:
Hi, I use the following code to export and import a file Excel from resp. into a Web page with the following code: //EXPORT Response.Clear(); Response.Buffer = true; Response.ContentType =...
3
by: Iavor Raytchev | last post by:
Hello, We a situation with a central database that contains the data that needs to be presented at N off-line terminals (N can be 5 000 can be 15 000). Each terminal presents unique data. The...
0
by: jen78 | last post by:
Hi, I am new to Oracle administration and hope someone can help me out on this as i am struggling to make it work.... I am doing development work using oracle database on my own development...
4
by: Max2006 | last post by:
Hi, We are developing a SQL server based asp.net application. As part of requirement we should allow users import/export some relational data through web user interface. We are investigation...
8
by: =?Utf-8?B?Ym9iYnk=?= | last post by:
Could you please help me in this project. I have aTab delemeted file. It has 20 columns and some data. I have to import this data into SQL Server. I am using sql express edition. I am using...
3
by: sumanta123 | last post by:
Hi All, I am using this command exp dev/dev@uatdb file='C:\database\dbbackup.dmp' for export the data from my database.It is successfully export into the dbbackup.dmp file. While import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.