Move an Excel file while in Access using VBA

J

jimtotem

I want to move an excel file, from within Access 2002, from one folder to
another.
I know that there is .movefile but I cannot get it to work, I'm not
defining the "object" correctly.
Thanks for your help.
Jim
 
J

jimtotem

I'm sorry Doug, but I am missing something:
I am having trouble "physically" moving and Excel (xls) file from one
location (folder) to another, based on an event in my Access program. I
think that the "object.movefile source, destination" will work, except I
don't know how to create the object for the Excel file. Does this make sense?
Thank you again for listening to me
Jim
 
D

Douglas J. Steele

You don't need to create an object or anything.

All you need is that one line of VBA Code (ok, 5 if you count the
declarations and assignment statements)

Dim strNewName As String
Dim strOldName As String

strOldName = "C:\MYDIR\OLDFILE.XLS"
strNewName = "C:\YOURDIR\NEWFILE.XLS"
Name strOldName As strNewName

The VBA Name statement will move the file if the source folder is different
than the destination folder.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top