I′ve the code below that loops through the folders on the path where the excel file is saved and applies a set of parameters. The code works great on a local folder on my drive. However, on a local folder saved on Onedrive it does not work and provides the error 76 "Path not found".
I believe the problem sits with the Application.ActiveWorkbook.Path
that delivers a link and not a path.
Does any one have any suggestion on how to solve this problem? Thanks.
Se image below to where i′m trying to open the file
Sub getfolders()
Dim objFSO As New FileSystemObject
Dim objFolder As Object
Dim objSubFolder As Object
Dim i As Integer
Dim FldName As String
Set objFolder = objFSO.GetFolder(Application.ActiveWorkbook.Path)
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row ' guarda o indice da ultima linha com conteudo da coluna B. Mesmo havendo vazios identifca a ultima linha
Length = Range(Range("B8"), Range("B" & Lastrow)).Rows.Count ' dimens?o da coluna C ate a ultima celula com conteudo come?ando na C7
For i = 0 To Length ' loop na coluna B
For Each objSubFolder In objFolder.SubFolders
(rest of the code...)
question from:
https://stackoverflow.com/questions/65871956/vba-loop-through-folders-on-onedrive 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…