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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I convert a file extension into document type?

Status
Not open for further replies.

MILLER09

IS-IT--Management
Nov 19, 2003
9
AU
Hi,

I'm new to VB and need help. My problem is this:
1. I have a list of files saved in an Access Database in the following form: file:///file_name.extension_type
for example,
-----------------------------------
ID_Num | File_Path
-----------------------------------
0 | file:///file_name0.doc
-----------------------------------
1 | file:///file_name1.txt
-----------------------------------
2 | file:///file_name2.xls
-----------------------------------
3 | file:///file_name3.mdb
-----------------------------------


How do I return the document type of each file found in File_Path? e.g. .mdb returns database, .xls returns spreadsheet ...

Thankyou,

neuralSea
 
Here is code that will display a file's type, just ensure you have added the Microsoft Scripting Runtime library to your references.


Dim fso As New FileSystemObject
MsgBox fso.GetFile("c:\myfile.txt").Type


ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
Hi Lonnie,

Thankyou for your help. This seems too simple to be true. Will this short bit of code just separate the file extension from the file name and return it or can it also return the type of document that this extension is in place of?

I assume that a getFilePath using DAO has to be inserted in place of C:\myfile.txt" to return the extension type for each record in the database?

Sorry to possibly sound extremely naive but my programming background is Fortran and C and I haven't done them for a while!

Regards,

Emmett
 
Yes, you would iterate through the recordset and put the file path in the section where I have c:\myfile.txt.

As far as your first question, yes it is that simple. What this does is get the data from the column in windows explorer that displays the type of file for each name in the explorer window.

ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top