vba - 如何正确简单地确定 OneDrive 物理路径?
问题描述
这个问题在 Stack Overflow 上出现过很多次,但我找不到既简单又有效的解决方案。这是我的代码:
Public Function GetPhysicalPath() As String
Dim objFso As FileSystemObject
Set objFso = CreateObject("Scripting.FileSystemObject")
Dim strOneDrivePath As String
strOneDrivePath = ActivePresentation.Path
Dim strAbsolutePath As String
strAbsolutePath = objFso.GetAbsolutePathName(strOneDrivePath)
Dim strPhysicalPath As String
If InStr(1, strOneDrivePath, "https://") > 0 Then
strOneDrivePath = Replace(strOneDrivePath, "https://", "https:\")
strOneDrivePath = Replace(strOneDrivePath, "/", "\")
strPhysicalPath = Replace(strAbsolutePath, strOneDrivePath, vbNullString)
Else
strPhysicalPath = strOneDrivePath & "\"
End If
GetPhysicalPath = strPhysicalPath
Set objFso = Nothing
End Function
问题是当我打开一个文件时,这个函数有时返回的不是实际的物理路径,而是C:\Users\User1\Documents
. 在我执行SaveAs
并覆盖实际上在同一个地方的同一个文件之后 - 一切正常。为什么会发生这种情况?
解决方案
推荐阅读
- python - AttributeError:模块'numbers'在scripy中没有属性'Integral'
- parsing - 如何在antlr4中使用Listener方法获取解析器的内容?
- python - py2exe 不工作 - 闪烁控制台并关闭
- python - 带有旋转/缩放/剪切/平移提取的 3D 点云配准(知道对应关系)
- javascript - 如何使用双向数据绑定将一个文本替换为另一个文本?
- python - 为什么我的 val_loss 下降但我的 val_accuracy 停滞不前
- ruby-on-rails - 在 kubernetes 中运行 rails + postgres:连接被拒绝
- flutter - 如何在 Firestore 查询中使用 DocumentReference
- c# - 获取程序要连接的 IP 地址
- .net - 如何在 docker 中安装 .net 框架?