This is why it is always good to have another set of eyes look at your
code. I believe part of the problem is that you are setting the
MyDestination2 path but then when you set MyNewFile2 you use
MyDestination as the path.
MyDestination2 = "\\mcplwpshrc1\department$\Accounting\Plus
Multipliers\Plus Recon\PACONT07\"
MyNewFile2 = MyDestination & "PACONT07" &
Format(f1.DateLastModified - 1, "_mmddyy") & ".txt"
Bill Palmer
Financial Coordinator, Information Systems
Mid-Columbia Medical Center
The Dalles, OR 97058
541-296-7417
>>> On 3/14/2008 at 7:39 AM, in message
<[EMAIL PROTECTED]>,
"Rodgers Chase" <[EMAIL PROTECTED]> wrote:
Can anyone tell me why this code is bugging out?
The first copy is working, but the second copy (with mmddyy format)
isn*t.
I highlighted in YELLOW and RED font the part that is bombing.
Sub CopyPACONT07()
'
Dim shell
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
'the following dims are used by CONT07 code
Dim MyPath As String
Dim MyDestination As String
Dim MyDestination2 As String
Dim MyFile As String
Dim MyNewFile As String
Dim MyNewFile2 As String
Dim MyName
Dim MyNameWithPath
Dim RetVal
'
'copies the daily PACONT07 report to two different places
MyPath = "\\Mcplwpshrc1\document$\VPOM\"
MyName = Dir(MyPath & "pacont07*.txt", vbDirectory)
MyNameWithPath = MyPath & MyName
MyDestination = "\\mcplwpshrc1\department$\Accounting\Plus
Multipliers\Plus Recon\673\"
MyNewFile = MyDestination & "PACONT07.txt"
Do While MyName <> ""
fso.CopyFile MyNameWithPath, MyNewFile, True
MyName = Dir
MyNameWithPath = MyPath & MyName
Loop
MyDestination2 = "\\mcplwpshrc1\department$\Accounting\Plus
Multipliers\Plus Recon\PACONT07\"
MyNewFile2 = MyDestination & "PACONT07" &
Format(f1.DateLastModified - 1, "_mmddyy") & ".txt"
Do While MyName <> ""
fso.CopyFile MyNameWithPath, MyNewFile2, True
MyName = Dir
MyNameWithPath = MyPath & MyName
Loop
'
Set fso = Nothing
'
End Sub
Thanks,
Chase Rodgers
Financial Reporting Manager
Medical Center of Plano
(214-473-7490
/[EMAIL PROTECTED]