Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Apr 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Accessing document properties without opening

    I have a module in my Excel workbook that needs to check for the presence of a file in a particular folder on a shared Netware drive. The folder has the FileScan permission turned OFF. This means VB code can open, modify, erase and write files but users can't use the FileOpen dialogue or Windows Explorer to access the files.

    My problem is that to test the existence of a file normally involves the DIR VB command. But, DIR uses FileScan ! So, I've kludged Application.Open and Application.Close commands to test whether the file exists but it's slow and ugly.

    Is there a better way of testing whether a file exists when FileScan is not permissable ? I've noticed that in Windows Explorer, it is possible to get document properties without opening files in the parent application. Can that be replicated in VB code ?

    Many thanks
    <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Accessing document properties without opening

    Just a thought but this might work.
    Try using the VBA function GetAttr(Pathname) where pathname is the file (or folder) you want to work with. You could do an error trap to handle the case where the file does not exist.

  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing document properties without opening

    I don't know whether this will work for you or not.

    I have used Scipting to test for files. I add a reference to "Microsoft Scripting Runtime", then:

    Dim fs As Object
    Set fs = CreateObject("Scripting.FileSystemObject")
    If fs.fileexists("c:temp.doc") Then ...
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  4. #4
    Lounger
    Join Date
    Apr 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Accessing document properties without opening

    Many thanks for both suggestions.

    I tried GetAttr but keep on getting a "53" file not found error whether the file is actually there or not. So, it seems getattr accesses FileScan in some way.

    The Scripting reference is off by standard on our network and I don't have authority to change it (I can't rely on it being present on all PCs).

    So, many thanks but, I think I'll stick with my FileOpen test which is working.

    [img]/w3timages/icons/frown.gif[/img]
    <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

Posting Permissions

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