By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,234 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,234 IT Pros & Developers. It's quick & easy.

Question in .vbs script to pull export from Access

P: n/a
I have a .vbs script that I'm running from the Windows destkop (intend
to have it run by Windows' task scheduler) to pull an export from MS
Access. Here's the script:

' **************************
dim objAccess
Set objAccess = CreateObject("Access.Application")

ObjAccess.OpenCurrentDatabase("C:\codescratch\db1. mdb")

ObjAccess.DoCmd.TransferText acExportDelim, "Expout Export
Specification","table1", "C:\expout.txt", False, ""

ObjAccess.CloseCurrentDatabase
Set ObjAccess = Nothing

MsgBox "Script has finished running."
' **************************
....in this code, "Expout Export Specification" is an export spec I
defined in Access for this simple, 3-col. test table. Using it to
export from within Access works fine.

I get no errors in this script, but the output file is not updates
when this is run. No write to that file takes place. I am required
to have some kind of file present on the filesystem at, in this case,
C:\expout.txt or the script complains that it can't find the file.
That seems odd to me. But again, the file is not updated.

What am I doing wrong? Thanks!

bp
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
This won't automatically overwrite the existing file, I don't think.
You'd have to put a kill statement in your code before running the
export to delete the existing file first.

something like:

Public Function ExportFile()
On Error Resume Next

Kill ("C:\MyTestExport.txt")
DoCmd.TransferText acExportDelim, "MySpecification", "MyTable",
"C:\Test.txt", True
End Function
Nov 12 '05 #2

P: n/a
In article <bf**************************@posting.google.com >,
pi********@hotmail.com (Pieter Linden) wrote:
This won't automatically overwrite the existing file, I don't think.
You'd have to put a kill statement in your code before running the
export to delete the existing file first.

something like:

Public Function ExportFile()
On Error Resume Next

Kill ("C:\MyTestExport.txt")
DoCmd.TransferText acExportDelim, "MySpecification", "MyTable",
"C:\Test.txt", True
End Function


Hmm...

As I understand, the TransferText method does indeed overwrite the file
if it is present. It is odd to me that it must be present or I receive
a file-not-found error, as well.


bp

--
Heisenberg may have slept here.
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.