473,770 Members | 6,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VBA code to Import in Access 2007

DAF LAD
8 New Member
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.RunComma nd acCmdImportAtta chExcel"

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 20527
missinglinq
3,532 Recognized Expert Specialist
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
rjgibson1985
3 New Member
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
12264
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 files are text and use tabs to delimit the column data. I can not use the File/Import as people using the program do not have the necessary experience to perform this function. Therefore, I need to programtically create unique tables for each...
4
1700
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 then have access to all my classes just like wx.Button or wx.BoxSizer etc. as of now i have a __init__.py file in the directory with: from pkgutil import extend_path __path__ = extend_path(__path__, __name__)
4
1408
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 Common/ __init__.py # does "from MyClass1 import MyClass1", etc,... MyClass1.py MyClass1a.py # depends on MyClass1
1
2684
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 form instead of being hard coded. So the user would select the sheet name from the drop down, click Import, and the VBA would import the tab the user selected. Also, different tabs would need to be imported to different tables. Is there a way to...
12
1880
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 commonly used functions and another package that contains all of my custom error classes. I want these error classes available to me in all of the other packages in my library. Currently to achieve this at the top of every module file I have the line...
4
10562
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 appropiate Pic field for each of the records - and "skip" a record if it's picture can't be found. ie StID=3076, Pic would import 3076.jpg. All jpgs are in the same folder, CafePics. Thanks
2
6295
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: DoCmd.DoMenuItem acFormBar, acFile, 2, 0, acMenuVer70 This line opens the import window. Does anyone know the replacement code to use in Access 2007 to open the import window?
4
3395
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 recognize the saved name as an import specification. Thanks for any help
12
11070
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 Option Explicit Dim cnn As ADODB.Connection Dim rst As New ADODB.Recordset Public Sub XptHoRpt() Dim strOfficeID As String
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10004
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8886
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7416
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.