Hi,
I have the following code but I got the error message saying that "Run-Time Error 424, Object Required". Wonder if someone could point out what the cause is, and how to rectify?
The code basically stops at the line: absPath = fso.GetAbsolutePathname(pathName).
However, if I rewrite the code this way, the error doesn't appear. Could someone please explain?
Thank you!
I have the following code but I got the error message saying that "Run-Time Error 424, Object Required". Wonder if someone could point out what the cause is, and how to rectify?
Code:
Sub callCFP()
pathName = "C:\Code\subFolder_1"
Set fso = CreateObject("Scripting.FileSystemObject")
CreateFullPath (pathName)
End Sub
Sub CreateFullPath(byVal pathName)
absPath = fso.GetAbsolutePathname(pathName) 'error occur on this line
end Sub
The code basically stops at the line: absPath = fso.GetAbsolutePathname(pathName).
However, if I rewrite the code this way, the error doesn't appear. Could someone please explain?
Code:
Sub callCFP()
pathName = "C:\Code\subFolder_1"
Set fso = CreateObject("Scripting.FileSystemObject")
absPath = fso.GetAbsolutePathname(pathName)
Debug.Print absPath
End Sub
Thank you!