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

Get Version Number for Files

Status
Not open for further replies.

PBAPaul

Programmer
Aug 3, 2002
140
GB
I have accumulated a number of downloaded files (system updates, shareware and freeware files) on my system.

I know that using Windows Explorer to examine the properties of the files, I can access the version number of some of them.

Does anyone know if this attribute can be accessed via VBA?

I want to do an analysis and tidy-up of the files and so have written an Excel VBA routine that lists all the files and shows the date the file was created etc. The problem is that most of these files I have had to copy onto my new system from an old system and so the file creation dates are mostly the same.

I know that I have at least three copies of a file titled HP_Update.exe and if I can automatically get the version number I can then automatically assign the oldest files for deletion.

Any help would be greatly appreciated.
 
Look into the FileSystemObject in the Scripting Runtime Library.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
FileSystemObject can get the creation date, but it can not get the Version Date.

Gerry
 
fso.GetFileVersion(pathspec)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
darn darn darn...I am just having a stupid day...time to go home...maybe have a nap.

Gerry
 
Hey PH, I have tried a number of files, and while GetFileVersion shows up as a method to use with fso, and I do not get a syntax error, it is ALWAYS fails on a run-time error. Any thoughts? I know I am having a stupid day, but hey what the heck, maybe things will improve.

Ooops, further news...ah, so sorry, GetFileVersion only works on executable files (.exe, dll, .scr etc).

However, this brings me to something, what can you use to get at those file properties like Comments, Revision (uh, not FileVersion....) Number etc that you can see from Windows Explorer. FileSystemObject does not get those...which is what I thought was in this post - although now I see the original post was about .exe files. Doh.

Gerry
 
A starting point:
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.NameSpace("C:\Temp")
set objFolderItem = objFolder.ParseName("Test.doc")
for i=0 to 21 ' Don't remember the number of details ...
wscript.echo i & "=" & objFolder.GetDetailsOf(objFolderItem, i)
next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PH & Gerry

Thanks for the posts. I will try PH's "starting point" post and see what I can get.

Paul
 
Hi PH,

what reference do I need for using wscript. I tried WMI Scripting, and Script Control, and Script Library, but wscript.echo gives an error - what is is declared as?

Gerry
 
My bad.
Replace WScript.Echo by MsgBox

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PH! Cool. Your routine gets details of a file without opening it. This could be very handy, as I actually DO use Comments and other document properties when writing/saving Word files.

OK, now, is there a way to WRITE to these? Say Comments (GetFolderDetails index = 5). I know how to do it within Word. You can write to most of these properties in VBA, but only with the document open. But it would be even better if I could access them without opening them.

I have tried using the SCID for Summary Info:

{F29F85E0-4FF9-1068-AB91-08002B27B3D9}

and while I can read using it, there does not seem to be a Property Set for it.

Possible?

Gerry
 
Hmmm. Don't have VB.Net, so I can't use the samples, or even get at them. I registered the DLL, and can reference it, but so far only get:

"Expected user defined type not project"

I will stumble along....

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top