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

Copy a File

P: n/a
I need to copy a file in a VBA module of an Access form, and I
haven't been able to find out how to do it: just

cp /Path1/file1 /Path2/file2
[my UNIX is showing]

Please show me how to do this in VBA for Windows.

thanks, --thelma
Oct 21 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Thelma Lubkin wrote:
I need to copy a file in a VBA module of an Access form, and I
haven't been able to find out how to do it: just

cp /Path1/file1 /Path2/file2
[my UNIX is showing]

Please show me how to do this in VBA for Windows.

thanks, --thelma
There is a command named "FileCopy".

FileCopy "source path" "destination path"

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Oct 21 '06 #2

P: n/a
Rick Brandt wrote:
Thelma Lubkin wrote:
I need to copy a file in a VBA module of an Access form, and I
haven't been able to find out how to do it: just

cp /Path1/file1 /Path2/file2
[my UNIX is showing]

Please show me how to do this in VBA for Windows.

thanks, --thelma

There is a command named "FileCopy".

FileCopy "source path" "destination path"
moving a file ...

Name "source path" As "destination path"

(don't know if the documenation supports this use but it seems to work)

Oct 21 '06 #3

P: n/a
"Lyle Fairfield" <ly***********@aim.comwrote in
news:11**********************@e3g2000cwe.googlegro ups.com:
Rick Brandt wrote:
>Thelma Lubkin wrote:
I need to copy a file in a VBA module of an Access form, and I
haven't been able to find out how to do it: just

cp /Path1/file1 /Path2/file2
[my UNIX is showing]

Please show me how to do this in VBA for Windows.

thanks, --thelma

There is a command named "FileCopy".

FileCopy "source path" "destination path"

moving a file ...

Name "source path" As "destination path"

(don't know if the documenation supports this use but it seems to work)
In Access 97:

Both newpathname and oldpathname must be on the same drive. If the path in
newpathname exists and is different from the path in oldpathname, the Name
statement moves the file to the new directory or folder and renames the
file, if necessary. If newpathname and oldpathname have different paths and
the same file name, Name moves the file to the new location and leaves the
file name unchanged. Using Name, you can move a file from one directory or
folder to another, but you can't move a directory or folder.

Using Name on an open file produces an error. You must close an open file
before renaming it. Name arguments cannot include multiple-character (*)
and single-character (?) wildcards.

Cheers,
Alan
Oct 23 '06 #4

P: n/a
Rick Brandt <ri*********@hotmail.comwrote:
: Thelma Lubkin wrote:
: I need to copy a file in a VBA module of an Access form, and I
: haven't been able to find out how to do it: just
:>
: cp /Path1/file1 /Path2/file2
: [my UNIX is showing]
:>
: Please show me how to do this in VBA for Windows.
:>
: thanks, --thelma

: There is a command named "FileCopy".

: FileCopy "source path" "destination path"

Thank you. This command allows me to overwrite an existing
/Path2/file2, which is what I want to do.

I ran into a problem while testing my use of it. I am copying an
Excel workbook that I use as an informal template to a file specified
by the Access form's user. I had set a breakpoint right after I opened
the new file and then did an immediate reset. After looking to assure
myself that the filecopy had indeed worked, I ran the form again: this
time filecopy erred out with a "Permission denied" message.

Ah, FileCopy won't overwrite open files. Ok, I deleted the supposedly open
workbook and tried again: "Permission denied". I exited Access, came
back in, tried again: "Permission denied". I couldn't get it to forget
that 'open file' until I exited the system and logged back on.

I don't know how to get around this problem, nor do I know whether
it's a problem within Access, VBA, Excel, or most probably, my tangled
operating system situation. I'm logging onto a University network of
PC's to use Access, but I store my data and results on a Unix machine,
so all kinds of disk mapping is going on. I'd appreciate suggestions
[other than the obvious 'why bring in Unix?']

--thanks, thelma
: --
: Rick Brandt, Microsoft Access MVP
: Email (as appropriate) to...
: RBrandt at Hunter dot com
Oct 24 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.