Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    U.S. - East Coast
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DSOFile fails for open document (Word 2000 SR-3)

    I'd like to use DSOFile to read custom version properties for Word, Excel, and PowerPoint files (templates, add-ins, documents, etc.). The component faithfully returns the document properties if a file is not open; however, the behavior varies among the different Office applications if the target document is open.

    DSOFile works fine with open Excel and PowerPoint documents as long as the file's Read-only attribute is on. In this case, DSOFile attempts to return information in a read-only format, which suits my purposes just fine. Word, however, returns run-time error 75 ("Path/File access error") if the target document is open, regardless of the setting of the read-only attribute.

    I've read the MS KB article (http://support.microsoft.com/?kbid=224351) often mentioned in similar threads. The article states "If the file is in use by another application when you try to open it, you get a trappable error telling you that the file is locked.", which I assume is the error 75 mentioned above. However, it goes on to state "If the file has been marked read-only or is located on an NT share that provides just Read access, the PropertyReader object tries to open the document in read access. " I interpret this to mean that if the read-only attribute is on, then DSOFile should succeed, which is my experience for PPT and Excel, just not for Word.

    Does anyone have a suggested work-around (if available), and is anyone aware of components similar to DSOFile? Thank you.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: DSOFile fails for open document (Word 2000 SR-3)

    Does this mean DSOFile is secretly opening the file rather than using some other kind of access? Word is very picky about that sort of thing, I'm not aware of any fix. I thought perhaps there might be a workaround at the OS level, but I don't get a Summary tab for an open Word .doc file, as I do with a closed Word .doc file (testing with Windows XP Pro). Bummer.

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    U.S. - East Coast
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DSOFile fails for open document (Word 2000 SR-3)

    The article indicates that DSO attempts to open the file with locking applied, and, failing that, attempts to open it read-only. It seems a bit odd that it would work for the other two Office apps since it would seem to be a limitation of the file system and not the application, but that's just a guess.

    I thought I would be able to use an API call to flip the read-only attribute, call the DSO method I need, then reset the attribute, but I can't even get the DSO method to work by manually flipping the read-only flag. Rats!

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: DSOFile fails for open document (Word 2000 SR-3)

    <P ID="edit" class=small>(Edited by jscher2000 on 01-Jun-04 21:16. )</P>I had an idea: how about pointing DSOfile at a copy of the file? Obviously some of the properties would be changed in the process of copying, but hopefully not the ones relevant to your application.

    This little bit of VBA seems not to trigger an open file violation (operating on the ActiveDocument in Word).

    Sub CopyToScratch()
    Dim strSourceFileName As String, fso As Object
    strSourceFileName = ActiveDocument.FullName
    Set fso = CreateObject("Scripting.FileSystemObject")
    fso.copyfile strSourceFileName, "c:scratch_fso.doc", True
    If Not (fso Is Nothing) Then Set fso = Nothing
    End Sub

    A VBScript version run off the desktop (see attached, source file name anonymized), also works. Can you use something like this?
    Attached Files Attached Files

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    U.S. - East Coast
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DSOFile fails for open document (Word 2000 SR-3)

    Jefferson,
    Great minds think alike! I had the same idea, but was concerned about making copies of potentially large (200+ pages, graphics-intensive) documents before I could even attempt to retrieve custom document properties. However, I just ran a test on a medium-sized file and, using FileSystemObject.CopyFile, was pleased to see that it took less than a second to copy the file.
    So, I'll probably use CopyFile if reading an open file fails. BTW, are you aware of any controls/dlls with functionality similar to DSO?
    Thanks for your always-excellent help.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: DSOFile fails for open document (Word 2000 SR-3)

    > are you aware of any controls/dlls with functionality similar to DSO?

    That's the only one I've heard of. Because Office binary file formats are proprietary, and the documentation must be requested from Microsoft (my request was ignored!), it's not the sort of thing I'd expect to find floating around in VB/VBA archives.

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: DSOFile fails for open document (Word 2000 SR-3)

    Ethan,

    Have never used them, but possibly Storage Tools by Desaware does something similar (not cheap though). There are links on that page to two white papers about Office document properties.

    Gary

  8. #8
    Star Lounger
    Join Date
    Jan 2001
    Location
    U.S. - East Coast
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DSOFile fails for open document (Word 2000 SR-3)

    Gary,

    Thank you for the information. Storage Tools certainly would accomplish my goal of accessing structured-storage properties externally to the host application, but the cost is prohibitive, as you mentioned. Still, it's good to know about such things, and Dan Appleman's suite of tools are usually of high quality, so I'll file the info. for future reference. Thanks again!

Posting Permissions

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