Hello Jonathan,
Thank you for posting in the community. My name is Billy and it's my pleasure to assist you
with this issue.
From your description, I understand that you would like to know how to issue the DOS
command from VBA to copy files. You can use the following two methods (Albert
mentioned) to copy a file in VBA. Here I provided you a detailed sample for your reference:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copy with the SHELL function
' to issue the DOS command
Dim MyCommand As String
Dim TaskId As Integer
' Create command string to copy the file to another directory.
MyCommand = "CMD /C Copy c:\filecopy1.txt d:\filecopy2.txt"
TaskId = Shell(MyCommand, 1)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copy with the FileCopy function
' to copy the file directly
Dim SourceFile, DestinationFile
SourceFile = "c:\filecopy1.txt" ' Define source file name.
DestinationFile = "d:\filecopy2.txt" ' Define target file name.
FileCopy SourceFile, DestinationFile ' Copy source to target.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For more information on how to use the Shell() function in Access Basic to run intrinsic MS-
DOS commands, please see the following KB:
116384 ACC: Using the Shell() Function to Run MS-DOS Commands
http://support.microsoft.com/?id=116384
Jonathan, does this answer your question? Please feel free to post in the group if this solves
your problem or if you would like further assistance. Thanks for posting in the community.
Best regards,
Billy Yao
Microsoft Online Support