All,
I need to modify the renaming of a file to include the month end date for the period. The problem is they may run the integration at either the end of the current month or in the first few days of the next month. I thought maybe to use pull the actual date they ran the Integration and use in an If then stmt:
If Day(Date)>27 than IMDate = Current Month End else IMDate = Last Month End -
The problem is I don't know how to write this code and how to put into the following script to make it function. I would think the easiest way would be to replace the Date with IMDate but not sure that would work:
sSourceFile = "C:\Documents and Settings\dan.bigelow\Desktop\SOP IMPORT\SOP_Invoice.txt"
sDestinationFile = "C:\Documents and Settings\dan.bigelow\Desktop\archive\CAN" & _
Year(Date) & _
Right("0" & Month(Date), 2) & _
Right("0" & Day(Date), 2) & _
"_Invoice.txt"
'Create a File System Object
Dim pFSO
Set pFSO = CreateObject("Scripting.FileSystemObject")
'Copy and rename the file
'The "True" parameter indicates that if the file already exists
'in the destination, then it will be overwritten
Call pFSO.CopyFile(sSourceFile, sDestinationFile, True)
Thank you,
Dan Bigelow
I need to modify the renaming of a file to include the month end date for the period. The problem is they may run the integration at either the end of the current month or in the first few days of the next month. I thought maybe to use pull the actual date they ran the Integration and use in an If then stmt:
If Day(Date)>27 than IMDate = Current Month End else IMDate = Last Month End -
The problem is I don't know how to write this code and how to put into the following script to make it function. I would think the easiest way would be to replace the Date with IMDate but not sure that would work:
sSourceFile = "C:\Documents and Settings\dan.bigelow\Desktop\SOP IMPORT\SOP_Invoice.txt"
sDestinationFile = "C:\Documents and Settings\dan.bigelow\Desktop\archive\CAN" & _
Year(Date) & _
Right("0" & Month(Date), 2) & _
Right("0" & Day(Date), 2) & _
"_Invoice.txt"
'Create a File System Object
Dim pFSO
Set pFSO = CreateObject("Scripting.FileSystemObject")
'Copy and rename the file
'The "True" parameter indicates that if the file already exists
'in the destination, then it will be overwritten
Call pFSO.CopyFile(sSourceFile, sDestinationFile, True)
Thank you,
Dan Bigelow