VBA Excel – 使用networkingpath名称不是驱动器号

我怎样才能从P改变下面的驱动器号来改为使用networking完整path名?

我似乎无法弄清楚

'Creating a FileSystemObject Public FSO As New FileSystemObject Sub DiskSpace() Dim drv As Drive Dim Space As Double Set drv = FSO.GetDrive("P:") ' Creating the the Drive object Space = drv.FreeSpace Space = Space / 1073741824 'converting bytes to GB Space = WorksheetFunction.Round(Space, 2) ' Rounding MsgBox "P: has free space = " & Space & " GB" End Sub 

修改以适应:

  Dim FSO As FileSystemObject Dim DRV As Drive Dim FO As Folder Dim sPath As String sPath = "\\RON-DODIER\Users" 'Network Folder Path Set FSO = New FileSystemObject Set FO = FSO.GetFolder(sPath) Debug.Print FO.Drive.FreeSpace 

您也可以使用File对象的Drive属性(如果这更多是您想要的)来确定可用空间量。