Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Extensions determined Programatically 2

Status
Not open for further replies.
Aug 24, 2004
98
0
0
US
I do have a lot of files without extensions in the name. Many of them are microsoft office files. We need to have some code that may check the files and determine if they are Excel, Word, etc. How could I accomplish this programatically? Any idea?


Thank you
 
jpinto1167,
are u sure that they have no extensions? do they have the proper icon? if so then the cpu has hide extensions of known file types checked. if not why are there no extensions?

regards,
lomghair
 
If they are Microsoft files, then they have extensions by default. Someone would have to deliberately go in, and NOT in the Office file dialog boxes and consciously change them.

Remember that Explorer, by default, does NOT show exntensions. You can turn this on, to show extensions.

Please confirm that they do not, in fact, have extensions. If they do not (and I would be surprised), then yes, it would be possible to work out file types.

Gerry
See my Paintings and Sculpture
 
longhair,

Thank you for your reply. To make the story short these are files extracted from a Lotus Notes NSF file (They are attachments to email). The problem is that when they were generated they were generated in such way that the extension do not exist anymore. Office is able to open them right if you try to open with the right office program. They just displayed themselves with the generic file icon. Any idea on how could I get them?

Thank you
 
jpinto1167,
i don't think you can do this with vba, since the file you open with xls may be a doc. i seem to remember that there are a sequence of bytes in the file that identify what the file was created with but i don't remember where they are stored in the file or what they are. if you could find out the sequence and what they are mapped to (file type) and where they are located you could probably do this with a vb program or bat file.

regards,
longhair
 
jpinto1167,
if you right click the mail message and open with notepad do you see a reference to what type of office file it is? for example open one that you know opens with excel and do a search for excel. does it find anything?

regards,
longhair
 
Hi jpinto1167

Check out this Addin ?? May help


What this does is gets the Microsoft office Doc. properties
{You'll need to select File type "*")
It will tell you if it is NOT a MSO Doc other wise it will load in the File details .... one of which is the ProgID, ie Excel, Word etc.

HTH

Ivan F Moala
xcelsmall.bmp
 
Thank you for your help Moala and the others. I am able to use different tools in some files but there are many cases in which I do not get anything from the utility that Moala showed me but still the file opens in the right application when I double click it at the Windows explorer. When I open the file with Notepad I do not find any expression saying Excel or Word, etc. Any idea?
 
jpinto1167,
if the file opens with a program that can 'read' it automatically then there should be an entry in the registry. try using regedit to search for the file name. i'm wondering if maybe some of the files that open with excel are actually lotus spreadsheets. maybe the word files are from word perfect or some other program.

hth
regards,

longhair
 
Longhair,

The files were extracted from Lotus Notes and they are Microsoft files (At least they contain the right extension at the inbox there).

Anyway, Could you explain to me how do I use the Regedit to investigate about files?

Thank you
 
jpinto1167,
so you are saying that when you look at the attachment on the email it says ????.xls but when you drop it onto the desk top it says only ????
then when you double click it it automatically opens with excel
correct?

regards,
longhair
 
Longhair,

Thank you for all the help that you are bringing to me.

We use a product called UniAccess to convert the files from Lotus Notes into Microsoft Outlook. If I copy the file directly from the email into the desktop, it works all right. The problem again is when I process them with Uniaccess.

Thank you

 
jpinto1167,
is there an option with uniaccess to keep the file extension?

regards,
longhair
 
I had been using the techinque offered by IvanMoala about the Microsoft DLL but I would like also to capture data for PDFS, Text Files and others. Do you know of any way of doing this?

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top