ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can not change default folder to network resource (https://www.excelbanter.com/excel-programming/361058-can-not-change-default-folder-network-resource.html)

side_[_3_]

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 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

--
side
-----------------------------------------------------------------------
side_'s Profile: http://www.excelforum.com/member.php...fo&userid=1945
View this thread: http://www.excelforum.com/showthread.php?threadid=54063


Dave Peterson

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

Ivan Raiminius

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


Dave Peterson

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

Ivan Raiminius

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


Dave Peterson

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

side_[_4_]

Can not change default folder to network resource
 

Thanks for you help.

Regards,
Side


--
side_
------------------------------------------------------------------------
side_'s Profile: http://www.excelforum.com/member.php...o&userid=19458
View this thread: http://www.excelforum.com/showthread...hreadid=540630



All times are GMT +1. The time now is 08:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com