hi,
I'm looking for a vba that would allow delete last 10 numbers from a file name.
1234561234567899 should be changed to 123456
1454541234566579 should be changed to 145454
etc...
I made a google and find out something like below (with few updates from my side)... unfortunately it is not working - so I would like to ask for some support...
Sub ZeroOutMinutesInFilenames()
Dim LastDot As Long, Path As String, Filename As String, NewFilename As String
Path = "C:\Users\Documents\invoices"
Filename = Dir(Path & "*.txt")
Do While Len(Filename)
LastDot = InStrRev(Filename, ".")
NewFilename = Application.Remove(Filename, LastDot - 10, 0, "")
Name Path & Filename As Path & NewFilename
Filename = Dir()
Loop
End Sub
thanks in advance
regards
I'm looking for a vba that would allow delete last 10 numbers from a file name.
1234561234567899 should be changed to 123456
1454541234566579 should be changed to 145454
etc...
I made a google and find out something like below (with few updates from my side)... unfortunately it is not working - so I would like to ask for some support...
Sub ZeroOutMinutesInFilenames()
Dim LastDot As Long, Path As String, Filename As String, NewFilename As String
Path = "C:\Users\Documents\invoices"
Filename = Dir(Path & "*.txt")
Do While Len(Filename)
LastDot = InStrRev(Filename, ".")
NewFilename = Application.Remove(Filename, LastDot - 10, 0, "")
Name Path & Filename As Path & NewFilename
Filename = Dir()
Loop
End Sub
thanks in advance
regards