ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple file extensions causing issues (https://www.excelbanter.com/excel-programming/433955-multiple-file-extensions-causing-issues.html)

XP

Multiple file extensions causing issues
 
Our org converted to XL2007 and we have a LOT of legacy programs out there
that use/populate/manipulate multiple files.

In the past, there was only one working file extension, XLS. Now, with our
legacy files, there could be three: XLS, XLSX, XLSM (I know there are several
other types, but these are the primary three that we would be using).

Now, since there are several different file extensions, many of our programs
will misfire when looking for target files. Anyone have any suggestions on
how to deal with this neatly in code? I'd hate to have to set up an
"If...Then..." everytime to try each file extension...any ideas?

Thanks in advance for your help.

Jacob Skaria

Multiple file extensions causing issues
 
"*.xl*" should cover all..

If this post helps click Yes
---------------
Jacob Skaria


"xp" wrote:

Our org converted to XL2007 and we have a LOT of legacy programs out there
that use/populate/manipulate multiple files.

In the past, there was only one working file extension, XLS. Now, with our
legacy files, there could be three: XLS, XLSX, XLSM (I know there are several
other types, but these are the primary three that we would be using).

Now, since there are several different file extensions, many of our programs
will misfire when looking for target files. Anyone have any suggestions on
how to deal with this neatly in code? I'd hate to have to set up an
"If...Then..." everytime to try each file extension...any ideas?

Thanks in advance for your help.


ker_01

Multiple file extensions causing issues
 
I prefer Jacob's solution, but here is an alternative just as an FYI; it
checks the file type instead of the file extension. You could also rework
this into a case statement instead of an extended OR statement.

'snippet based on fil.type
For Each fil In fld.Files
If fil.Type = "Microsoft Office Excel 2007 Workbook" Or _
fil.Type = "Microsoft Excel Worksheet" Or _
fil.Type = "Microsoft Office Excel Macro-Enabled Worksheet" Or _
fil.Type = "Microsoft Office Excel 2007 Macro-Enabled Workbook"
Or _
fil.Type = "Microsoft Office Excel 97-2003 Worksheet" Then
ListFilesPriv = ListFilesPriv & ";" & fil.Path
End If
Next


"xp" wrote:

Our org converted to XL2007 and we have a LOT of legacy programs out there
that use/populate/manipulate multiple files.

In the past, there was only one working file extension, XLS. Now, with our
legacy files, there could be three: XLS, XLSX, XLSM (I know there are several
other types, but these are the primary three that we would be using).

Now, since there are several different file extensions, many of our programs
will misfire when looking for target files. Anyone have any suggestions on
how to deal with this neatly in code? I'd hate to have to set up an
"If...Then..." everytime to try each file extension...any ideas?

Thanks in advance for your help.



All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com