Created
January 17, 2024 08:43
-
-
Save YujiFukami/97c7ab5baabcc77310a43cf927189ef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function ConvOneDrivePath_LocalPath(ByRef Path As String) As String | |
'OneDriveのhttp形式のパスをローカル上のパスに変換する | |
'20231218 | |
'https://d.docs.live.net/********/作業フォルダ/2023年/12月/Book.xlsm | |
'↓ | |
'C:/Users/[ユーザー名]/OneDrive/作業フォルダ/2023年/12月/Book.xlsm | |
'参考 | |
'https://www.softex-celware.com/post/ConvOneDrivePath_LocalPath | |
'引数 | |
'Path・・・変換対象のフォルダパス | |
'処理 | |
Dim Output As String | |
Dim TmpSplit As Variant | |
If Path Like "http*" Then | |
'パスがhttpから始まるので変換の必要あり | |
TmpSplit = Split(Path, "/") '「/」で分割 | |
TmpSplit(0) = "" | |
TmpSplit(1) = "" | |
TmpSplit(2) = "" | |
TmpSplit(3) = Environ("OneDrive") | |
Output = Join(TmpSplit, "\") '\で結合する | |
Output = Mid(Output, 4) | |
Else | |
'変換の必要なし | |
Output = Path | |
End If | |
'出力 | |
ConvOneDrivePath_LocalPath = Output | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment