VBA cannot move this file to a folder. Weirdness

hellfire45

Active Member
Joined
Jun 7, 2014
Messages
447
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.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. 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
447
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
12,979
Office Version
  1. 2013
Platform
  1. 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,129,563
Messages
5,637,077
Members
416,956
Latest member
mitzhaki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top