If I had a network at home, this would be easy, as I could map a network drive to S:\, upload the files there, and I'm good to go. Actually, I do have this, but this means that I'd have to upload the files to my server, work on them, then download them to take them back to work tomorrow. And I'm way too lazy to do all that. So instead I spent some time working on a better alternative. J
I now have a little VB script which maps the S:\ drive to my "C:\My Documents\Work Stuff" folder. I run the script, and Excel doesn't have a clue that it isn't working with the S:\ drive at work. No re-pointing of links required, not futzing around uploading files to my server.
Here's the script, (I actually replicate the H:\ drive too) which makes use of the DOS SUBST (or Substitute) command:
Dim objShell, strDrive1, strDrive2, strPath Set objShell = CreateObject("WScript.Shell") strDrive1 = "H:" strDrive2 = "S:" strPath = """C:\My Documents\Work Stuff""" objShell.Run "cmd /c SUBST " & strDrive1 & " " & strPath, 1, True objShell.Run "cmd /c SUBST " & strDrive2 & " " & strPath, 1, True
Dim objShell Set objShell = CreateObject("WScript.Shell") On Error Resume Next objShell.Run "cmd /c SUBST H: /d" objShell.Run "cmd /c SUBST S: /d"
NOTE: The triple quotes on strPath in the first routine are required to feed a single set of quotes to the cmd. This is necessary to allow spaces in the file path.
Hopefully you'll never find this useful, as that means you're taking your work home!
(NOTE: Much of this can now be avoided with products like OneDrive, DropBox and others.)
Rate this article