Runtime 1004 error on existing file

Pobek

Board Regular
Joined
Jul 7, 2015
Messages
99
I am getting this error when I point my macro to a file in a specific directory. Problem is THE FILE IS THERE!!! There are some actions that I have taken:

1. I made copies of the same file with varying length in names.

2. The file with the shorter names are found whilst sometimes the files with the longer names have part of the end cut of (i.e. a runtime error when a filename such as "September-DB" is being looked for under "Septembe" .... cutting off the "r-DB". HOW ON EARTH IS THIS THE CASE!????

3. Copied all the input files in their input folder to a shorter directory (a Path not so long) and for this shorter path, the macro finds all files (including the ones with longer names).

It seems that there is something that is making my code cut of the end of some of my file names particularly if they are sitting in a long and deep file-path ... could there be a limit to the length programmed somewhere? I doubt this as its not the 1st time I have developed models that look for long file names in deep and long file-paths ... HELP!!

I have a 2013 excel.
 
OK, try changing the message box line to this now:
Code:
MsgBox Opfile
Then, when you get an error, check to make sure that you actually have a file by that exact name that currently exists in that exact file path.
I suspect that there may be an error in there somewhere.

Trust me I have, but I'll do it again just to make sure.
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Yes, be sure to check very carefully for things like spaces, I's that look like 1's, 0's that look like O's, etc.

Some other things I have seen trip people up before:
1. The path is different for different people (due to drive mappings, permissions, etc). Make sure that you can open it by browsing to the exact same path in Windows Explorer.
2. There is an issue with the file (already open, corrupt, bad extension so it cannot be opened). Can you browse to it and open it manually via Excel?
 
Upvote 0
Yes, be sure to check very carefully for things like spaces, I's that look like 1's, 0's that look like O's, etc.

Some other things I have seen trip people up before:
1. The path is different for different people (due to drive mappings, permissions, etc). Make sure that you can open it by browsing to the exact same path in Windows Explorer.
2. There is an issue with the file (already open, corrupt, bad extension so it cannot be opened). Can you browse to it and open it manually via Excel?

Hi, how are you.

I have and it opens. I guess there some spaces there but that hasnt stopped it in the past.

One thing I did notice though is that part of the file extension was copied over from a usb. Now while the whole extension being referred to sits on my local drive, I notice that some of the sub-folders (the part copied from the usb drive) have a blue man-torso like figure on them. When I link the macro to an extension that has all folders originating from the C ... there are no issues. I suspect this might have something to do with it...what u think?
 
Upvote 0
I notice that some of the sub-folders (the part copied from the usb drive) have a blue man-torso like figure on them.
I have no idea what that is...
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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
Back
Top