Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Jan 2001
    Posts
    47
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Read Custom Database Properties in VB-Script (97 SR-2)

    I need to read custom version information of a database (.mdb file) from a VB-script and I hoped to avoid having the script open the mdb (because of security issues). Originally version information is stored as a property of the database object itself. To make it accessible from outside applications I duplicated this information to a custom property of the Databases!UserDefined document.
    I then had the idea to use the FileSearch object to read the property but I found that it can only search for a given property but not return a property of a found file. <img src=/S/disappointed.gif border=0 alt=disappointed width=15 height=15>
    Next approach was using Dsofile.dll which is provided by Microsoft for the purpose of "Editing Office Document Properties from VisualBasic" (kb article 224351). But although this object promises to give access also to custom properties it does not show me my custom "Versiondate" property (of dbDate type) that I can perfectly view in Access' standard database property dialog. <img src=/S/bwaaah.gif border=0 alt=bwaaah width=123 height=15> Are mdbs not "OLE strutured storage files" as native Excel, Word and Powerpoint documents?
    Any other solutions?

    Here's the code I use with dsofile.dll:

    Sub dptest()

    Dim objDocProp
    Dim objCustProp
    Dim strBuf
    Dim strInfo

    Set objDocProp = GetDocumentProperties("C:My.mdb")

    For Each objCustProp In objDocProp.CustomProperties
    strBuf = objCustProp.Name & ": " & CStr(objCustProp.Value)
    ' strBuf = strBuf & " [" & CustTypeName(objCustProp.Type) & "]"
    strInfo = strInfo & strBuf & vbCrLf
    Next

    MsgBox strInfo

    End Sub

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

    Re: Read Custom Database Properties in VB-Script (97 SR-2)

    Microsoft mentions only Word, Excel, PowerPoint and Visio in the download page for DSOFile.exe:
    <hr>Dsofile.exe is a self-extracting executable that provides a simple in-process ActiveX component for programmers to use in order to read and modify the Document Summary Properties for an OLE Structured Storage file such as native Excel, PowerPoint, Microsoft Visio, and Word documents without using Automation to Microsoft Office. The component can also work on non-OLE documents when it is run on Windows 2000 with an NTFS file system.<hr>
    The sample VB application that comes with DSOFile.exe fails on Access databases. So I'm afraid you're out of luck...

  3. #3
    Lounger
    Join Date
    Jan 2001
    Posts
    47
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Read Custom Database Properties in VB-Script (97 SR-2)

    > So I'm afraid you're out of luck...
    Yep, at least for the easy way (see below).

    > The sample VB application that comes with DSOFile.exe fails on Access databases.
    This is only partially correct. It's true that the DSOleFile.PropertyReader object cannot read or write Access 97 custom database properties (as can be seen with the sample VB app). But it CAN read and write custom properties in it's own OLE-format to an Access 97 MDB-file! So my solution is to not use the proprietary access properties but the ones that are featured by the PropertyReader object to which I point in the references of the MDB. These properties can then be read and set by the VB script. And on top of that, they are more secure in that they cannot be directly accessed by users via the access standard UI.
    I found that it is also possible to add OLE properties to an Access MDE file, but when converting a MDB to MDE they get lost.

    Thanks for your reply anway,
    Martin

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

    Re: Read Custom Database Properties in VB-Script (97 SR-2)

    Thanks Martin, it's good to know that - I hadn't tried to create OLE properties.

  5. #5
    Lounger
    Join Date
    Jan 2001
    Posts
    47
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Read Custom Database Properties in VB-Script (97 SR-2)

    One more thing to consider: Microsoft states, that "the component can also work on non-OLE documents when it it run on windows 2000 with an NTFS file system". I just tried it on W98SE with FAT32 and found the softies are right: Within this system you cannot read or write OLE-properties to a MDB file. Even worse: By merely copying a database with OLE properties from NTFS to FAT these properties are permanently lost. Thus Access 97 databases definitely do not belong to the group of "OLE Structured Storage files" - what a pity!

Posting Permissions

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