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

Redmoving a spreadsheet and replaicing it through Access

P: n/a
Hi:

I know that there is a "kill" command, which will remove files from my system, and that it
can be executed through Access.

Can someone tell me the form of the command to, say, remove a file with the path:
"C:/ipt/timesheets/passover.xls"
I would be executing it through a macro using ther "run code" function.

Thanks a lot

JOhn Baker

Jan 11 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Red
Kill is used to delete files, RmDir is used to delete directories

~Red

Jan 11 '06 #2

P: n/a
I !!!think!!! you will have to create a Procedure in a Standard Module
to do this, eg.

Public Function DeleteFile(ByVal FilePath As String)
Kill FilePath
End Function

Your Run Code Macro then will have an argument (Function Name):
DeleteFile ("C:/ipt/timesheets/passover.xls") .

Common errors in this endeavour include:
Using a Sub instead of a Function; TTBOMK Macros cannot run Subs;
Failing to include the parentheses as in DeleteFile
"C:/ipt/timesheets/passover.xls"; one would call the function directly
in VBA without the parentheses but not in a Macro.

Then where are we?
We have had to write a VBA procedure.
The procedure has no error handling, yet.

So one wonders, why not use the VBA without the Macro?

Some comments:
Kill is an archaic and dangerous method. Put some kind of a wild card
in your arguments with Kill and you could lose many files.

Of course, someone may know a better Macro way to do the same thing
that Kill does.

Jan 11 '06 #3

P: n/a
Why do you have to remove it first? Using TransferSpreadsheet, it will just
overwrite the existing spreadsheet. The only time you run into a problem is
if you have the spreadsheet open in Excel when you try to run the procedure.
Here's an example of something I have used:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"YourTableOrQueryName", "C:\downloads\" & strFileName, True

Linda

"John Baker" <jo********@comcast.net> wrote in message
news:gf********************************@4ax.com...
Hi:

I know that there is a "kill" command, which will remove files from my
system, and that it
can be executed through Access.

Can someone tell me the form of the command to, say, remove a file with
the path:
"C:/ipt/timesheets/passover.xls"
I would be executing it through a macro using ther "run code" function.

Thanks a lot

JOhn Baker

Jan 11 '06 #4

P: n/a
Red
I very may be wrong, but while looking through some code of mine, I do
believe that A97 doesn't overwrite, because I damn sure wouldn't have
written an extra line of code if I didn't have to ;)
~Red

Jan 11 '06 #5

P: n/a
Thank you all for your help. The Dragon has been Slain, and I am now able to move ahead.

Thanks again

John Baker

John Baker <jo********@comcast.net> wrote:
Hi:

I know that there is a "kill" command, which will remove files from my system, and that it
can be executed through Access.

Can someone tell me the form of the command to, say, remove a file with the path:
"C:/ipt/timesheets/passover.xls"
I would be executing it through a macro using ther "run code" function.

Thanks a lot

JOhn Baker


Jan 12 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.