Map drive to open a file with code

  • Thread starter Thread starter Les Stout
  • Start date Start date
L

Les Stout

Hello all, is it possible to "map" to a network drive, open a file and
then "disconnect" the drive again with code ? This is necessary as not
all users have access to the drive which is also password protected.

Any help would be appreciated...

Best regards,

Les Stout
 
Why not just open the file via the UNC name.

You can do it in the file|open dialog or you can do it in code:

Dim wkbk as workbook
set wkbk = workbooks.open(Filename:="\\server\share\folder\file.xle")
 
Hello Dave, this drive is not mapped in all cases... I tried your
suggestion but it does not find the file and it is there. If i map the
drive then it works fine but that is the initial problem...

Best regards,

Les Stout
 
The drive doesn't need to be mapped to a letter if you refer to it by its UNC
path.

Try recording a macro when you open the file manually using that UNC path.

Maybe you mistyped something in the code and the recorded macro will help you
find it.
 
Back
Top