Multiple file extensions causing issues

X

xp

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.
 
K

ker_01

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top