+ Reply to Thread
Results 1 to 7 of 7

Can not change default folder to network resource

Hybrid View

  1. #1
    Registered User
    Join Date
    02-04-2005
    Posts
    6

    Can not change default folder to network resource

    Hello,

    I have faced strange problem with the following code:

    DefCatalogue = ThisWorkbook.Path
    ChDir (DefCatalogue)
    nFileNum = FreeFile
    Open "Message.txt" For Input Access Read As #nFileNum

    It was working fine when both workbook and Message.txt were located on local drive. But when I have moved both files to network resource i.e. "\\PC_3\shareddocs\Shared files\Tmp" the code breaks on file open statement and it happens because ChDir does not make any changed to default directory.

    Does anyone have any ideas why it does not work?

  2. #2
    Dave Peterson
    Guest

    Re: Can not change default folder to network resource

    Chdir doesn't work with UNC paths. There's an API that you could use to change
    to that drive, but I don't think you need to in your code:

    DefCatalogue = ThisWorkbook.Path
    nFileNum = FreeFile
    Open defCatalogue & "\" & "Message.txt" For Input Access Read As #nFileNum



    side_ wrote:
    >
    > Hello,
    >
    > I have faced strange problem with the following code:
    >
    > DefCatalogue = ThisWorkbook.Path
    > ChDir (DefCatalogue)
    > nFileNum = FreeFile
    > Open "Message.txt" For Input Access Read As #nFileNum
    >
    > It was working fine when both workbook and Message.txt were located on
    > local drive. But when I have moved both files to network resource i.e.
    > "\\PC_3\shareddocs\Shared files\Tmp" the code breaks on file open
    > statement and it happens because ChDir does not make any changed to
    > default directory.
    >
    > Does anyone have any ideas why it does not work?
    >
    > --
    > side_
    > ------------------------------------------------------------------------
    > side_'s Profile: http://www.excelforum.com/member.php...o&userid=19458
    > View this thread: http://www.excelforum.com/showthread...hreadid=540630


    --

    Dave Peterson

  3. #3
    Ivan Raiminius
    Guest

    Re: Can not change default folder to network resource

    Hi,

    I am afraid that neither open works with UNC paths (the path must start
    with a letter).

    Regards,
    Ivan


  4. #4
    Dave Peterson
    Guest

    Re: Can not change default folder to network resource

    Are you sure?

    I don't have the ability to test that anymore, but that's not the way I recall.



    Ivan Raiminius wrote:
    >
    > Hi,
    >
    > I am afraid that neither open works with UNC paths (the path must start
    > with a letter).
    >
    > Regards,
    > Ivan


    --

    Dave Peterson

  5. #5
    Ivan Raiminius
    Guest

    Re: Can not change default folder to network resource

    Hi Dave,

    you are right, I just tried open with UNC path and it works.

    Thanks,
    Ivan


  6. #6
    Dave Peterson
    Guest

    Re: Can not change default folder to network resource

    Thanks for posting back with your test results.

    Ivan Raiminius wrote:
    >
    > Hi Dave,
    >
    > you are right, I just tried open with UNC path and it works.
    >
    > Thanks,
    > Ivan


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1