strSourceDataFile = ActiveSheet.Range("B2").Value & arrFileNames(Y)
strDataDestination = "\\localserver\Network Folder\"
strDataFilename = XXXX.xls
FullDataFile = strDataDestination & strDataFilename
'Check to see if the data file already exists in the destination folder
If fso.FileExists(FullDataFile) Then
'Check to see if the file is read-only
If Not fso.GetFile(FullDataFile).Attributes And 1 Then
'The file exists and is not read-only. Safe to replace the file.
fso.CopyFile strSourceDataFile, strDataDestination, True
Else
'The file exists and is read-only.
'Remove the read-only attribute
fso.GetFile(FullDataFile).Attributes = fso.GetFile(FullDataFile).Attributes - 1
'Replace the file
fso.CopyFile strSourceDataFile, strDataDestination, True
'Reapply the read-only attribute
fso.GetFile(FullDataFile).Attributes = fso.GetFile(FullDataFile).Attributes + 1
End If
Else
'The file does not exist in the destination folder. Safe to copy file to this folder.
fso.CopyFile strSourceDataFile, strDataDestination, True
End If
Every single time I run this. I get into the said error. would really appreciate if someone would help me
Bookmarks