gpt4 book ai didi

excel - VBA 03 - 应用程序路径 - 到达父文件夹

转载 作者:行者123 更新时间:2023-12-01 22:32:02 24 4
gpt4 key购买 nike

应用程序:Excel

Left(ThisWorkbook.Path, InStrRev(ThisWorkbook.Path, "\") - 1)

我需要从工作簿路径返回至少 2 个文件夹。

无法使用“C:/Folder1”等路径,因为应用程序将被移动多次。

最佳答案

像这样:

Function getParentFolder2(ByVal strFolder0)
Dim strFolder
strFolder = Left(strFolder0, InStrRev(strFolder0, "\") - 1)
getParentFolder2 = Left(strFolder, InStrRev(strFolder, "\") - 1)
End Function


Dim strFolder
strFolder = getParentFolder2(ThisWorkbook.Path)

我们在这里剪切了两次\subdir 模式...

关于excel - VBA 03 - 应用程序路径 - 到达父文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19904376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com