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] 

Reply via email to