I am getting a Compile error: Method or data member not found on the .GetFileName When I…
Jump to turn (17)
- 1I am getting a Compile error: Method or data member not found on the .GetFileNam
- 2same error but now on this line VBA.FileSystem.Rename filePath, VBA.FileSystem.G
- 3Error on the Rename
- 4on this line of code VBA.FileSystem.Rename filePath, VBA.Strings.Left(filePath,
- 5Microsoft Scripting Runtime is enabled
- 6same error but on .Name(filePath) =
- 7with the new line of code, error on Rename VBA.FileSystem.Rename filePath, VBA.S
- 8getting a Compile error: Method or data member not found on the FileExists
- 9error on the Rename
- 10VBA script editor does not like the AS
- 11same erro but on .GetParentFolderName
- 12error now on Name
- 13VBA editor does not accept As at the end of the code
- 14at the very end of the code, error is on Name. Sub RenameFile() Dim rng As Range
- 15error still on Name in the last line
- 16method or data member not found, error on Name in the last line
- 17same error message but now on Rename
- User
I am getting a Compile error: Method or data member not found on the .GetFileName
When I change it to fileName = VBA.FileSystem.Name(filePath) , I still get the same error
Runtime Scripting is enabled
Sub RenameFile()
Dim rng As Range Dim cell As Range Dim fileName As String Dim filePath As String Dim processedFlag As String
Set rng = ActiveSheet.UsedRange.Columns("A:B")
For Each cell In rng.Cells
If cell.Column = 1 Then ' Check if the cell has a hyperlink If cell.Hyperlinks.Count > 0 Then filePath = cell.Hyperlinks(1).Address fileName = VBA.FileSystem.GetFileName(filePath) End If ElseIf cell.Column = 2 Then ' Check for the processed flag processedFlag = Trim(cell.Value) If processedFlag = "Processed" Then ' Rename the file with PRO prefix VBA.FileSystem.Rename filePath, VBA.FileSystem.GetParentFolderName(filePath) & "\PRO" & fileName End If End If Next cell
End Sub
- Assistant