Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Dir function (Word 2003)

    In one VBA project, I consistently get an error with the following line of code:

    If Len(Dir("H:Apps", vbDirectory)) Then

    The error occurs on the nested Dir statement and the error is File or Path Not Found. This is code that I use very frequently for many purposes; I've never had this occur before. I've added error trapping to the function so that it returns FALSE if an error occurs as well as if Len = 0.

    This occured recently in one global template; I use the identical code in several other global templates with no ill effect. Could there be a reason for this?

    Thanks,
    Richard

  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: Dir function (Word 2003)

    Could it be a permission setting on the server, on/in whatever share "H" represents?

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: Dir function (Word 2003)

    It could well be something like that. When I test for this particular path, I (obviously) know that it might not exist. The usual reason is that a laptop is out of its docking station and the network is not available. For some reason, the local login script still sets some environment variables to H:. That apparently "confuses" Windows into thinking that the drive & path must be present, when in fact they are not.

    Thanks for getting me thinking!

  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: Dir function (Word 2003)

    There is an API to check whether a network connection is disconnected, if you want to go that far, but it sounds as though error handling might be easier.

Posting Permissions

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