ape*_*arr 24 excel ms-access vba excel-vba ms-access-97
由于各种原因,我陷入了Access 97并且只需要获取完整路径名的路径部分.
例如,名称
c:\whatever dir\another dir\stuff.mdb
Run Code Online (Sandbox Code Playgroud)
应该成为
c:\whatever dir\another dir\
Run Code Online (Sandbox Code Playgroud)
该网站提供了一些有关如何操作的建议:http: //www.ammara.com/access_image_faq/parse_path_filename.html
但它们看起来相当可怕.必须有更好的方法,对吧?
Mak*_*kah 41
你可以做一些简单的事情: Left(path, InStrRev(path, "\"))
例:
Function GetDirectory(path)
GetDirectory = Left(path, InStrRev(path, "\"))
End Function
Run Code Online (Sandbox Code Playgroud)
Joh*_* Mo 19
我总是用FileSystemObject
这种东西.这是我使用的一个小包装函数.一定要参考Microsoft Scripting Runtime
.
Function StripFilename(sPathFile As String) As String
'given a full path and file, strip the filename off the end and return the path
Dim filesystem As New FileSystemObject
StripFilename = filesystem.GetParentFolderName(sPathFile) & "\"
Exit Function
End Function
Run Code Online (Sandbox Code Playgroud)
小智 10
这似乎有效.以上不适用于Excel 2010.
Function StripFilename(sPathFile As String) As String
'given a full path and file, strip the filename off the end and return the path
Dim filesystem As Object
Set filesystem = CreateObject("Scripting.FilesystemObject")
StripFilename = filesystem.GetParentFolderName(sPathFile) & "\"
Exit Function
End Function
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
91787 次 |
最近记录: |