473,395 Members | 1,872 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,395 software developers and data experts.

Automate Import-Export in Access

Hello,

I'm new to Office(!) but not to programming. I have a requirement that I'm struggling to solve:

1. In Access, I import a List from a sharepoint site as a linked table.
2. I delete all the data in the list.
3. I import an Excel file from my local system onto this linked table.
4. Save and close.

How can I automate this?

I've tried:
1. Macro->Open Table, but this does not fetch an http:// link
2. Save Import Steps, but this option not available for Linked tables.

Is there a way I can do this via command line? Are Access functions available thru cmd ?

I'm using Access 2007 btw.

Thanks and will appreciate any response :)
Narayana
Jan 23 '08 #1
5 11769
MMcCarthy
14,534 Expert Mod 8TB
There are a number of options available... one of which is programmatically linking or relinking tables.

Expand|Select|Wrap|Line Numbers
  1. Private Function ReconnectTables() As Boolean
  2. On Error Resume Next
  3. Dim tdf As DAO.TableDef
  4. Dim dbs As DAO.Database
  5. Dim strPath As String
  6. Dim strConnect As String
  7.  
  8.     Set dbs = CurrentDb
  9.     'Set the path to the backend
  10.     strConnect = "\\full path to source file"
  11.     'Reconnect the tables
  12.     For Each tdf In dbs.TableDefs
  13.         If tdf.Connect = "Linked Table Name" Then ' substitute the name of your linked table
  14.             tdf.Connect = ";DATABASE=" & strConnect
  15.             tdf.RefreshLink
  16.         End If
  17.     Next
  18.  
  19.     Set dbs = Nothing
  20.     If Err.Number = 0 Then ReconnectTables = True
  21.  
  22. End Function
  23.  
Feb 5 '08 #2
Glynn
5
@msquared
Will this work in the opposite direction?

In Access, I have a linked Excel Spreadsheet.
I have a query that selects unique records from the Excel Spreadsheet.
I have exported the output of the select as an XML file to SharePoint site, and saved the Export.
What I would like to do is automate the running of the "saved export"

Any thoughts?

Thanks in advance
Dec 10 '09 #3
MMcCarthy
14,534 Expert Mod 8TB
Sorry for the delay in replying, I was away with work this week.

I'm not sure exactly what you are trying to do. If you are just appending data to a table then you can just run the query in code. However, if you are trying to create an xml file then the only way I know of to do this is by Writing to a text file. Does the following code help ? I used something similar to create a labelling xml file recently.

Expand|Select|Wrap|Line Numbers
  1. Function LabelsToXML(label As Integer)
  2. Dim db As DAO.Database
  3. Dim rs As DAO.Recordset
  4. Dim strDestFile As String
  5. Dim iFileNum As Integer
  6.  
  7.     Set db = CurrentDb
  8.     Set rs = db.OpenRecordset("SELECT * FROM Linked_Excel_File")
  9.     strDestFile = "Path to new xml File"
  10.     iFileNum = FreeFile
  11.  
  12.  
  13.     Open strDestFile For Output As #iFileNum
  14.     ' If an error occurs report it and end.
  15.     If Err <> 0 Then
  16.         MsgBox "Cannot open filename " & strDestFile
  17.         End
  18.     End If
  19.  
  20.     Print #iFileNum, "<?xml version=""" & "1.0" & """ standalone=""" & "no""" & "?>"
  21.     Print #iFileNum, "<labels _QUANTITY=""" & "1" & """ _PRINTERNAME=""" & strPrinter & """>"
  22.     Print #iFileNum, "<label _FORMAT=""" & strLabel & """ _QUANTITY=""" & qty & """>"
  23.  
  24.         ' do this for each field
  25.         Print #iFileNum, "<variable name=""" & rs1.Fields("FieldName or index").Name & """>" & rs1.Fields("FieldName or index").Value & "</variable>"
  26.  
  27.     Print #iFileNum, "</label></labels>"
  28.     Close #iFileNum
  29.  
  30. End Function
  31.  
Dec 18 '09 #4
Glynn
5
Thank you for your reply. My solution was to create a query against the linked in Excel spreadsheet which was XML exported to the sharepoint site.

Then I saved the export xml and initiated it with a DoCmd.RunSavedImportExport, which worked.

Thanks again,

Glynn
Dec 18 '09 #5
MMcCarthy
14,534 Expert Mod 8TB
Glad you got it working. I forgot 2007 had an export to xml facility. Unfortunately the application I was working on was in 2003.

Mary
Dec 18 '09 #6

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

Similar topics

2
by: Phil Latio | last post by:
We have despatch process which kicks out picking information into text files at hourly intervals. The text files are named sequentially by process; 'ABC.txt', 'ABC01.txt', 'ABC02.txt' for one...
25
by: MLH | last post by:
In an earlier post entitled... "A97 closes down each time I open a particular report" it has been suggested that I rebuild problematic table - one in which some corruption has occurred. I...
11
by: David Lozzi | last post by:
Hello, I need to automate importation of a excel file into a table. Here's my scenario: I'm writing an ASP.NET application where users can pull reports on imported data. The imported data is...
11
by: gert365 | last post by:
I'm working on a scirpt to be used on a windows machine and I need to automate a user's input on the command prompt. For example I'm using os.system('mycommand') to excute the commands I want. ...
3
by: D | last post by:
I would like to write a program that will automate the configuation of a firewall or router via HTTPS. So, I need to import the applicable certificate, and be able to configure the unit as if I...
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
1
by: sklett | last post by:
I've never tried to use windows messages to automate an application, but I've read some different blogs and articles that talk about sending keyboard input and mouse input. I wanted to describe...
3
by: Kenneth McDonald | last post by:
I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken
2
by: =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post by:
Is it possible to automate a COM object ebmeded in an excel document run the process and return the results in a C# .NET application? Or better yet extract the com object some how and just run it...
0
by: ishay44 | last post by:
Hello! I try to build (using Visual 2005 and Excel 2007) the example described in the Microsoft Help and Support "How to automate Excel from MFC and Visual C++ 2005 or Visual C++ .NET to fill or...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...

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.