Copy a File Type

Learn2010

Registered User.
Local time
Today, 17:21
Joined
Sep 15, 2010
Messages
415
I have to create a flat file to send to a group each month. The file type I create is M(a 7 digit number).(a three digit number), like M1234567.123. I create it as a text file and rename it from a field on a form. The field is in the last line of code below, WaiverFile.

START OF CODE

Dim NewFormName As String
DoCmd.TransferText acExportFixed, "WaiverFiles", "qryViewWaiverBilling",
"C:\PSWaiverFiles\PSWaiverFile.txt", False, ""
Dim stFileLoc As String stFileLoc = "C:\PSWaiverFiles\"
FileCopy stFileLoc & "PSWaiverFile.txt", stFileLoc & Forms!frmDailyLogOptions!WaiverFile

END OF CODE

I have a procedure that this is part of. The next thing I need after the code above is to copy this file, M1234567.123, or “M?.?”, to a folder on a mapped drive, that is T:\PSWaiverFiles. I need to copy it as M*, so that I can get the file every time. I have tried several things, including:

START OF CODE

FileCopy “C:\PSWaiverFiles\M*”, “T:\PSWaiverFiles”

END OF CODE

Can someone provide some help?

Thank you.
 
I found another way to do it. I created a vbs script file that copied the file type from one folder to another. Then, the next line of code I used a Shell "WScript command to call it.

Thanks.
 
The basic method I use is

Code:
Dim objFileSystem As Object
Dim strOldPath As String, strNewPath As String
strOldPath = "X:\SomeFolder\Folders\FileName.FileExt" 'Folder file to copy
strNewPath = "X:\SomeFolder\AnotherFolder\FileName.FileExt" 'Folder to copy file to
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
objFileSystem.CopyFile strOldPath, strNewPath
Set objFileSystem = Nothing
 

Users who are viewing this thread

Back
Top Bottom