473,405 Members | 2,160 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,405 software developers and data experts.

VBA code to Import in Access 2007

DAF LAD
Hi.

I have been running an access Database in Office 2003 for a while now. When I upgraded to Office 2007 one of my macro buttons has stopped working.

The Button looks up to VBA code to Import a specific Excel spread sheet from a specific location on my hard drive. This file is updated but never re-named or moved so to save time I have created the import macro to do the import steps for me.

This has been working fine for me in Office 2003. Once I upgraded to Office 2007 this has stopped working.

the code that I have been using is as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Import_PBs_Click()
  2. DoCmd.TransferSpreadsheet acImport, 0, _
  3. "z new pbs", "....\new pbscrs\newpbs.xls", True
  4. End Sub
where "z new pbs" is the table in access.

I have found that Office 2007 uses code starting: "DoCmd.RunCommand acCmdImportAttachExcel"

however I cannot seem to get this to automatically import the excel sheet, instead it opens the import wizard.

I have the imports saved in the "saved imports" wizard but i want to be able to run this from a macro button.

anyone have any suggestions?
Nov 19 '08 #1
2 20487
missinglinq
3,532 Expert 2GB
Code does not run in 2007 unless your database resides in a folder that has been declared a “trusted” location.

To trust your folder, click:

Office Button (top left)
Access Options (bottom of dialog)
Trust Center (left)
Trust Center Settings (button)
Trusted Locations (left)
Add new location (button)

Linq ;0)>
Nov 19 '08 #2
I was able to automate my Excel imports into Access 2007. I go into details here:

http://bytes.com/topic/access/answer...-a#post3525566
Nov 13 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Pete | last post by:
I need to import multiple tab delimited files for which I do not have the formats. All files have column headers in the the line. The files must be dynamic. The only common value is that the...
4
by: spohle | last post by:
hi, i have written a small project for myself all in seperate classes and each of the classes lives in a seperate file. now i am looking for an import structure something like import wx, and...
4
by: Brian Blais | last post by:
Hello, I am trying to organize some of my code, and am having a little trouble with the import logic. I find I often have something like: MyPackage/ Part1/ # wants to use functions in...
1
by: beingnick | last post by:
Hello, I am using Access 2007, but need to be compatible with 2003. I am importing a sheet from Excel into Access (code below). I would like the sheet name to be determined from a drop down on a...
12
by: xkenneth | last post by:
All, I apologize if this is a commonly asked question, but I didn't find anything that answered my question while searching. So what I have right now is a few packages that contain some...
4
by: EHOHP | last post by:
Access 2007 on XP Pro Each record contains two fields - StID (a unique ID number) and Pic (an attachment field to hold a jpg). Is it possible to create a batch import that places the picture in the...
2
by: Reedsp | last post by:
I have a Access 2000 formated database that I am testing the functionality of the database in Access 2007. One line of code of visual basic code in not working in a module. The line is: ...
4
by: davjoh123 | last post by:
I have saved an import and it works great. I would like to be able to start the saved import from a button on a switchboard. I tried using TransferText and the saved import name but it does not...
12
by: iheartvba | last post by:
Hi, I am trying to run a VBA procedure to send an e-mail every day at 9:00 PM. How would this be achieved. I'm not sure if this would help but the code is as follows Option Compare Database...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.