这个工作簿path – networking位置

在电子表格存储在Dropbox上的同时使用此代码返回:

Sub output_set() Dim s As String s = ThisWorkbook.Path outputstr = s & "\output\" end sub 

结果

 \\psf\Dropbox\test_folder\output\ 

我宁愿返回分配给此位置的驱动器号。

 W:\test_folder\output\ 

我怎样才能修改我的macros?

 Sub Tester() Debug.Print MappedDrivePath("\\psf\Dropbox\test_folder\output\") End Sub Function UncToMappedDrive(uncPath) As String Dim rv As String Dim objWMI As Object Dim disks As Object Dim disk As Object rv = "" Set objWMI = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\\.\root\cimv2") Set disks = objWMI.ExecQuery("Select * from Win32_MappedLogicalDisk") For Each disk In disks If uncPath Like disk.ProviderName & "*" Then rv = Replace(uncPath, disk.ProviderName, disk.Name) Exit For End If Next disk UncToMappedDrive = rv End Function