-
if you are using xls file you have to change this line
Code:
strExt = ".xlsm" 'Change to suit
to
Code:
strExt = ".xls" 'Change to suit
-
-
are you working with last version ? I don't think
-
Hi, Pleace see post №10. There are the problem in the picture.
I use excel 2003 and excel 2007.
Thank you.
-
For last version I mean the last code I pasted
-
Hi, I'm totally confused.
What you can not understand me and what is the last of what you write.
Penultimate and last macro work, but if once has stored in a new file in our example Ivan Ivanov 0001 or Ivan Ivanov-1 or Ivan Ivanov 1 - it does not matter, then stored on it my friend, and I want to create a new file with a serial number, and I can not do anything, if you attach an excel file?
Maybe when you run things (code), but to me it does not. I'll try again to explain:
1 Open the "Ivan Ivanov" - write something.
2 Press the "save" I mean macro
3 in my folder already have a new file - "Ivan Ivanov-0001" or "Ivan Ivanov-1" or whatever
4 re-open the "Ivan Ivanov" - write something
5 Press "save" I mean macro
6 in my folder should have a new file, but number 2 - "Ivan Ivanov-0002" or "Ivan Ivanov-2" or whatever it is there
And in my case I hit the macro (button), he replaced it on the old "Ivan Ivanov-0001" or "Ivan Ivanov-1" or whatever it is there
Am I wrong somewhere or code not working?
Thanks in advance
-
with this code
Code:
Sub saveProgressiveNumber1()
Dim newFileName As String, strPath As String
Dim strFileName As String, strExt As String
strPath = "C:\Users\ivan\Desktop\" 'Change to suit
strFileName = "Ivan Ivanov" 'Change to suit
strExt = ".xlsm" 'Change to suit
newFileName = strFileName & "-" & GetNewSuffix(strPath, strFileName, strExt) & strExt
ActiveWorkbook.SaveCopyAs strPath & newFileName
End Sub
Function GetNewSuffix(ByVal strPath As String, ByVal strName As String, ByVal strExt As String) As Integer
Dim strFile As String, strSuffix As String, intMax As Integer
strFile = Dir(strPath & "\" & strName & "*")
Do While strFile <> ""
strSuffix = Mid(strFile, Len(strName) + 2, Len(strFile) - Len(strName) - Len(strExt) - 1)
If Mid(strFile, Len(strName) + 1, 1) = "-" And CSng(strSuffix) >= 0 And _
InStr(1, strSuffix, ",") = 0 And InStr(1, strSuffix, ".") = 0 Then
If CInt(strSuffix) >= intMax Then intMax = CInt(strSuffix)
End If
strFile = Dir
Loop
GetNewSuffix = intMax + 1
End Function
if you run macro you can save with progressive number, if you want save the original file with original name you have to save it normally.
-
Hello, apparently the problem is with me, so I ask you to look at video file that show what's where and how to set my folder after number 1, number 2 is missing.
-
Don't change anything in Function GetNewSuffix, you can change the path only in the sub
-
2 Attachment(s)
Okay, but if i do not change out my error immediately.
See photo:
Attachment 987
Attachment 986