Path Name issue for file opened from Z drive

B

Barb Reinhardt

I have mapped server \\server\ to my Z drive. When I open files from this
mapped drive and display the workbook.path, it doesn't show Z, but it shows
\\server\filename.xls. Is there some way to have it keep the Z drive without
hard coding the mapping?

Thanks,
Barb Reinhardt
 
G

Gary''s Student

Maybe its the mapping technique. From a command window issue:

net use Z: /delete /y
net use Z: "\\server\" /PERSISTENT:yes

Of course, make sure the full server path is in the second command. The
commands can be put in a .bat or a .wsh file, if you prefer.

Then from My Computer, open the Z: drive and then open the Excel file by
double-clicking the icon.

Then:

Sub ordinate()
MsgBox (ThisWorkbook.Path)
End Sub
 
B

Barb Reinhardt

Wonderful! It's remapped when I'm connected to the Office network, but when
I'm working offsite, I have to remap it myself, otherwise I can't get to
anything programmatically. This is a snippet of code that I use when I map
it offsite in a VBScript file. Is there something I should change.
Admittedly, I'm not a VBScript expert.

Set objNetwork = Wscript.CreateObject("WScript.Network")
strUserName = objNetwork.UserName

on error resume next
objNetwork.MapNetworkDrive strdirectory, strpath & strusername

Thanks,
Barb Reinhardt
 
G

Gary''s Student

I don't know.
--
Gary''s Student - gsnu200800


Barb Reinhardt said:
Wonderful! It's remapped when I'm connected to the Office network, but when
I'm working offsite, I have to remap it myself, otherwise I can't get to
anything programmatically. This is a snippet of code that I use when I map
it offsite in a VBScript file. Is there something I should change.
Admittedly, I'm not a VBScript expert.

Set objNetwork = Wscript.CreateObject("WScript.Network")
strUserName = objNetwork.UserName

on error resume next
objNetwork.MapNetworkDrive strdirectory, strpath & strusername

Thanks,
Barb Reinhardt
 

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

Top