Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jan 2004
    Location
    Kfar Sava, Israel
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Retrieving Custom Document Properties (Office 2003)

    Couldn't find this issue in the archives so here goes:

    I have a standard list of custom document properties I use in every Word document.
    I have no problem retrieving these properties from inside the active document with ActiveDocument.CustomDocumentProperties

    However, I need a list of these properties for ALL the doc files in a certain directory (and subdirectories) on the fileserver,
    and I was wondering if I can access the custom document properties WITHOUT opening each file, getting the values, storing them somewhere, closing the file, etc.
    The only clue I found on the subject till now was to use Dsofile.exe, but it seems to me that Dsofile.exe is only good for use in VB, not VBA.

    Has anyone got better ideas on how to do the above?

    TIA,

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Retrieving Custom Document Properties (Office 2003)

    If you have downloaded and executed DSOFile.exe, the DSOFile.dll will be installed and registered on your system. You can use it in VBA behind any Office application by setting a reference to it:

    - Select Tools | References... in the Visual Basic Editor.
    - Locate and tick DS: OLE Document Properties 1.4 Object Library.
    - Click OK.

    You can now use code like this:

    Dim oFilePropReader As New DSOleFile.PropertyReader
    Dim oDocProp As DSOleFile.DocumentProperties
    Dim sFile As String
    sFile = "C:MyFolderMyDocument.doc"
    Set oDocProp = oFilePropReader.GetDocumentProperties(sFile)
    MsgBox oDocProp.Author
    Set oDocProp = Nothing
    Set oFilePropReader = Nothing

    For ideas on how to use the DLL in code, study the VB6 example that is installed along with the DLL. Even if you don't have VB6, you can view FileProp.frm in Notepad or any other text editor, it is a plain text file. The second half of the file contains the VB code.

    Note for others reading this: DSOFile.exe can be downloaded from MSKB article Dsofile.exe Lets You Edit Office Document Properties from Visual Basic and ASP.

  3. #3
    New Lounger
    Join Date
    Jan 2004
    Location
    Kfar Sava, Israel
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Retrieving Custom Document Properties (Office 2003)

    Thanks Hans.
    I set the reference to the DSOFile as you suggested, and that solved half the problem - I could get the inbuilt doc properties, but not the custom ones.
    With some help from the example on http://www.cpearson.com/excel/docprop.htm, I managed to get the custom properties too.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •