File and extension issue

cstimart

Well-known Member
Joined
Feb 25, 2010
Messages
1,180
I've resolved some issues with opening files w/unknown extensions (.xls, .xlsx, .xlsm) and preventing code from crashing when a file (with a known extenstion) does not exist.

http://www.mrexcel.com/forum/showthread.php?t=547920
http://www.mrexcel.com/forum/showthread.php?t=533029

Now, I would like to know how I can resolve a combination of these issues.

How would I code to open a file by a derived name with an unknown extension and NOT crashed when the derived file name does not exist (regardless of the extension)?

Basically, I'm working with 2, possibly 3 files. The code runs in the Master file (1), utilizes the revision date of a Daily file (2) to then open the source file (3) that includes the aforementioned date. However, that source file has situations when it may not exist and/or could possible have the different excel extensions.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Change this....
strFileAndPath = strPath & Dir$(strPath & strFileName & ".xl*")

To this...
strFileAndPath = strPath & Dir$(strPath & strFileName & ".*")
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,919
Members
452,949
Latest member
beartooth91

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