Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1539
  • Last Modified:

export an access table into excel using vbscript

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
Sailo100
Asked:
Sailo100
  • 3
1 Solution
 
pootle_flumpCommented:
Hi

What's your script?
0
 
pootle_flumpCommented:
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
 
Sailo100Author Commented:
Hi

that works great thanks, one more question if was importing data into access then would
acImport = 2 ??
0
 
pootle_flumpCommented:
Easiest way to check - debug the constants in the immediate window of VB\ VBA

?acImport
 0
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now