ThisWorkbook.FullName returns a URL after syncing with OneDrive. I want the file path on disk

前端 未结 3 1325
清酒与你
清酒与你 2021-01-13 16:58

I have a workbook on OneDrive. Usually, ThisWorkbook.FullName returns a path on disk:

c:\\Users\\MyName\\OneDrive - MyCompany\\BlaBla\\MyWorkbook 09-21-17.xl         


        
3条回答
  •  -上瘾入骨i
    2021-01-13 17:15

    Sub get_folder_path()
    
    'early binding
    Dim fso As FileSystemObject
    Set fso = New FileSystemObject
    
    'late binding
    'Dim fso As Object
    'Set fso = CreateObject("Scripting.FileSystemObject")
    
    Dim folder As String
    folder = fso.GetAbsolutePathName(ThisWorkbook.Name)
    Debug.Print (folder)
    

提交回复
热议问题