VBA cannot move this file to a folder. Weirdness

hellfire45

Active Member
Joined
Jun 7, 2014
Messages
444
I have a process that is processing and then moving about 60 files to an archive. For some reason this one file cannot be moved.

The files name is: (very long I know, can't help it)
1 2 2018 - xOpen Line Report for y and AVOCENT Product POs RMAs as of 01 02 2018 - x Backlog Report as of 01 02 2018 -y z

It's giving me Run-time error 76 Path Not Found. I find this weird since it does not give this error for any of the other 60 or so files. The file is not corrupt.

The relevant code I'm using is below:

Code:
folderpath = "I:\ASM\All\CRT\Reporting\In Consolidation Process\Reports\"

If Dir("I:\ASM\All\CRT\Reporting\In Consolidation Process\Master Automation\Dated Report Archive\" & Format(Date, "yyyy-mm-dd"), vbDirectory) = "" Then
            MkDir ("I:\ASM\All\CRT\Reporting\In Consolidation Process\Master Automation\Dated Report Archive\" & Format(Date, "yyyy-mm-dd") & "\")
End If

destinationpath = "I:\ASM\All\CRT\Reporting\In Consolidation Process\Master Automation\Dated Report Archive\" & Format(Date, "yyyy-mm-dd") & "\"



fso.MoveFile folderpath & strFileName, destinationpath & strFileName
strFileName is a variable that changes to reflect each file name in the folder. They are all .xlsx files


Thank you yet again friends.
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
11,762
Office Version
2013
Platform
Windows
My guess would be that your share server has a limit for the number of characters for a file name, which includes the path. But I have no solution to offer as a work around.
 
Last edited:

hellfire45

Active Member
Joined
Jun 7, 2014
Messages
444
My guess would be that your share server has a limit for the number of characters for a file name, which includes the path. But I have no solution to offer as a work around.

Maybe I can manually change this particular pain in the butts file name to something short and then trying to transfer it.
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
11,762
Office Version
2013
Platform
Windows
You could try it to see if that is the problem. But changing the file name would make it difficult to find in the future. I think I would do a little QE and see if the source can't do a better job of naming the files.
 

Watch MrExcel Video

Forum statistics

Threads
1,095,395
Messages
5,444,228
Members
405,275
Latest member
RefreshSQL

This Week's Hot Topics

Top