im looking for a macro that can save a copy of a file called "master pack" and save it in the same location with a new name picked from a certain cell.
then repeated when run saving a copy of "master pack" with a new name.
The code below is the closest iv got but this save a new copy with 1 in front and then when run again has an error.
Sub copyfileinSameFolder()
Set fs = CreateObject("Scripting.FileSystemObject")
oldpath = "D:\test"
newPath = "D:\test"
Prefix = "1_"
Set f = fs.getfolder(oldpath)
Set NFile = f.Files
For Each pf1 In NFile
NameFile = pf1.Name
filecopy oldpath & "\" & NameFile, newPath & "\" & Prefix & NameFile
Next
End Sub
im sure this code just needs a small amount changing can anybody help?
then repeated when run saving a copy of "master pack" with a new name.
The code below is the closest iv got but this save a new copy with 1 in front and then when run again has an error.
Sub copyfileinSameFolder()
Set fs = CreateObject("Scripting.FileSystemObject")
oldpath = "D:\test"
newPath = "D:\test"
Prefix = "1_"
Set f = fs.getfolder(oldpath)
Set NFile = f.Files
For Each pf1 In NFile
NameFile = pf1.Name
filecopy oldpath & "\" & NameFile, newPath & "\" & Prefix & NameFile
Next
End Sub
im sure this code just needs a small amount changing can anybody help?