Function getExcelFolderPath2() As String
Dim fso As FileSystemObject
Set fso = New FileSystemObject
Dim fullPath As String
fullPath = fso.GetAbsolutePathName(ThisWorkbook.Name)
fullPath = Left(fullPath, Len(fullPath) - InStr(1, StrReverse(fullPath), "\")) & "\"
getExcelFolderPath2 = fullPath
End Function
Even though fullPath gets a string with relevant contents, getExcelFolderPath2 ends up being empty. This is from a break on that last line, just to be clear:
There must be something really simple that I'm missing, but I can't see it.
I expected to have getExcelFolderPath2 be equal to fullPath.
This is more a comment than an answer, but too long:
I guess the function works correctly. It works for me (and at least for user Dominique).
Could it be that you set the breakpoint on the statement getExcelFolderPath2 = fullPath
and then look to the Locals Window? When the runtime hits that statement and breaks, the statement itself is not executed.
But if you step to the end of the function, the function value is set
Call the function from the immediate window to check: