dj_West_Texas has asked for the wisdom of the Perl Monks concerning the following question:

Is there documentation that will tell me what OLE file property variables are available? I know some available properties from searching the web, but is there a place to find all of them?

For example, if I have correctly assigned a value to $filename (say temp.doc), the following lines of code will access the DateCreated and title properties.

my $PropertyReader = Win32::OLE->new('DSOleFile.PropertyReader', 'Quit +'); my $properties = $PropertyReader->GetDocumentProperties($filename); print "$filename DateCreated $properties->{'datecreated'} \n"; print "$filename title $properties->{'title'} \n";
But how do I know that 'datecreated' is the parameter to send to the GetDocumentProperties method?

What if I want the DateLastSaved property (or other properties that I don't know the magic parameter for)?

I am a pretty inexperienced Perl user. Have I missed something obscenely easy here?

Replies are listed 'Best First'.
Re: Win32::OLE::Variant variables
by dj_West_Texas (Initiate) on Dec 07, 2004 at 03:45 UTC
    I still haven't found exactly what I was looking for in any kind of documentation, but I was able to adapt some code from http://aspn.activestate.com/ASPN/Perl/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq12.html

    I modified the code there to just view the names of the constants provided by GetDocumentProperties. The code I used was:

    use strict; use Win32::OLE; use Win32::OLE::Const; my $filename="word.doc"; #my $properties = Win32::OLE::Const->Load("Microsoft Excel"); # use th +is to see Excel doc properties my $PropertyReader = Win32::OLE->new('DSOleFile.PropertyReader'); my $properties = $PropertyReader->GetDocumentProperties($filename); printf "Library contains %d constants:\n", scalar keys %$properties; foreach my $Key (sort keys %$properties) { print "$Key = $properties->{$Key}\n"; }
    You may use any word, excel or powerpoint document in place of word.doc

    This returns a list of the properties (38 of them) I was looking for.

    Tha parameter to include is just the property from the list below (in all lowercase).

    The properties:
    AppName, Author, ByteCount, CLSID, Category, CharacterCount, CharacterCountWithSpaces, Comments, Company, CustomProperties, DateCreated, DateLastPrinted, DateLastSaved, HasMacros, HiddenSlides, Icon, IsReadOnly, Keywords, LastEditedBy, LineCount, Location, Manager, MultimediaClips, Name, PageCount, ParagraphCount, PresentationFormat, PresentationNotes, ProgID, RevisionNumber, SlideCount, Subject, Template, Thumbnail, Title, TotalEditTime, Version, WordCount

    I have probably revealed an enormous depth of Perl-naivete in what I posted, but it did answer my most immediate need.

    I wasted many hours trying to find this information on the web and couldn't find this particular info anywhere. Hope it will help someone else with a similar need.

    I would still love for any gurus to point me to a better way to do this, or the unfound documentation that I was looking for. I would also be curious to know if I have missed any similar available file properties.
      Use the OLE Object Browser installed with ActiveState or for other things open up your "OLE-using" program of choice for example Excel. And open up its internal object browser .. which has pretty decent documentation.