Good evening all from NZ.
I have about 30 files to copy to a new folder & rename the files with the date format ddmmyyyy added at the end of the filename before the Ext identifier ie
filename.doc? to filename ddmmyyyy.doc? (I also need to modify actual files and want to do this via a macro iteration but one step at a time.
This project will be on going and having to do this 2 or 3 times a week. There are also repetitive tasks that need to happen within the files that need opening up, changing and saving. But one step at a time.
Here is a sample of an actual file name change
1.2 Annual Objectives.doc to 1.2 Annual Objectives ddmmyyyy.doc
I have 2 problems - the first is most files start with the numbering 1.4 Name*.*x
That is there is a "." in the 2nd position of the filename.
The other problem that I have varierty of filetypes xls, xlsx, doc, docx, pdf etc
to replace the "." with "ddmmyyyy." I have this code - (The "Find" is the problem in VBA)
strName = Replace(Find(".", A2, 6), " " & Format(Now(), "ddmmyyyy") & ".")
I found this code on this site which looks pretty good for what I want but I need to work out how find the location of the ext identifier and append the date to it.
'
Get the full name of the current attachment.
strAtmtFullName = atmt.FileName
' Find the dot postion in atmtFullName.
intDotPosition = InStrRev(strAtmtFullName, ".")
' Get the name.
strAtmtName(0) = Left$(strAtmtFullName, intDotPosition - 11)
' Get the file extension.
strAtmtName(1) = Right$(strAtmtFullName, Len(strAtmtFullName) - intDotPosition)
' Get the full saving path of the current attachment.
strAtmtPath = strFolderPath & atmt.FileName
What I need is code to find the ext identifier (the 2nd ".") and just before that 2nd identifier I want to insert the date in the format of ddmmyyyy.
BTW this code came from checksamir at
Bookmarks