Can not change default folder to network resource

  • Thread starter Thread starter side_
  • Start date Start date
S

side_

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 o
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 ope
statement and it happens because ChDir does not make any changed t
default directory.

Does anyone have any ideas why it does not work
 
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
 
Hi,

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

Regards,
Ivan
 
Are you sure?

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

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

Thanks,
Ivan
 
Thanks for posting back with your test results.

Ivan said:
Hi Dave,

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

Thanks,
Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top