Using Scripting.FileSystemObject. I would also like to automatically retrieve the FULL PATH and FILE NAME (as you can see from my code I have manually input the full path and file name). Once the code determines the FULL PATH and FILE NAME, I want to extract ONLY the first 4 (left) char’s of the file name then call this function in a cell in the worksheet. I am using Excel 2010 and the code below is what I currently have:
Function strWhatIsMyName()Dim strFName As String Dim FSO As FileSystemObject Dim objFile As File Set objfso = CreateObject(“Scripting.FileSystemObject”) Set objFile = objfso.GetFile(“C:NameOfFile.xls”) Wscript.Echo “Base name: ” & objfso.getbasename(objFile) strFName = objfso.getbasename(objFile) End Function
Thanks in advance.