Solved

export an access table into excel using vbscript

Posted on 2006-07-12
4
1,317 Views
Last Modified: 2008-01-09
Hi

I have a protected database which does not let me add modules, macros, queries or specifications to it.
I need to export the table from the database called "maintable" to excel.

Because i cant add a specification i can't use DoCmd.TransferText, so used DoCmd.TransferSpreadsheet

I know the following code works if run from a module ....

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "maintable", "C:\test.xls", True

but when i put it into a vbscript then it doesnt work.
I get error saying ...
"The microsoft jet database engine could not find the object 'C:\test.xls'. Make sure the object exists and that you spell its name and the path name correctly
error code 800A0BC3

I cant figure out why this is happening. Any ideas?
0
Comment
Question by:Sailo100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 11

Expert Comment

by:pootle_flump
ID: 17090234
Hi

What's your script?
0
 
LVL 11

Accepted Solution

by:
pootle_flump earned 250 total points
ID: 17090369
This code works fine:

SET oAcc = CREATEOBJECT("Access.Application")

oAcc.OpenCurrentDatabase "RemoteDB.mdb"

oAcc.DoCmd.TransferSpreadsheet 1, 8, "MyTable", "C:\test.xls", True ' acExport = 1, acSpreadsheetTypeExcel9 = 8
0
 

Author Comment

by:Sailo100
ID: 17090990
Hi

that works great thanks, one more question if was importing data into access then would
acImport = 2 ??
0
 
LVL 11

Expert Comment

by:pootle_flump
ID: 17092329
Easiest way to check - debug the constants in the immediate window of VB\ VBA

?acImport
 0
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question