![]() |
using a macro to map a drive
I am looking for a way to map a network drive with a macro when a user
opens a spreadsheet. Then when the user is done using the spreadsheet, another macro would disconnect the mapped drive. Does anyone know of a way to accomplish this? Any help would be appreciated. |
using a macro to map a drive
Have the workbook open event macro call something like this:
Sub mapp_um() dq = Chr(34) s = "net use z: /delete /y" ss = "net use z: " & dq & "\\myServ\Shared" & dq & " /PERSISTENT:no" x = Shell("cmd.exe /c" & s, 1) x = Shell("cmd.exe /c" & ss, 1) End Sub In this example I used Z: as the drive. The initial delete is just in case Z: is already being used. Trap the workbook close event and have it call something like: Sub unmap() dq = Chr(34) s = "net use z: /delete /y" x = Shell("cmd.exe /c" & s, 1) End Sub This releases Z: -- Gary''s Student - gsnu200727 " wrote: I am looking for a way to map a network drive with a macro when a user opens a spreadsheet. Then when the user is done using the spreadsheet, another macro would disconnect the mapped drive. Does anyone know of a way to accomplish this? Any help would be appreciated. |
using a macro to map a drive
Just curious why you have to map that drive. I would think that most things
(all things???) would work ok if you used the UNC path. wrote: I am looking for a way to map a network drive with a macro when a user opens a spreadsheet. Then when the user is done using the spreadsheet, another macro would disconnect the mapped drive. Does anyone know of a way to accomplish this? Any help would be appreciated. -- Dave Peterson |
All times are GMT +1. The time now is 04:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com