Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Excel 2007 Save Workbook with Next Generic Filename 1

Status
Not open for further replies.

Salut39

Technical User
Aug 2, 2006
178
GB
Hi Everyone!

I have workbook NR0000529.xlsm.

I need to create a lot more copies of this file with the next number: NR0000530.xlsm,NR0000531.xlsm...

How Could this be done with the macro.

Thanks in advance,

Yuri
 
Filecopy" to create a copy of a file.
"Format" function with a serial number as one of arguments to create a part of a file name with formatted number.

combo
 


hi,

Will the new name ALWAYS be relative to the active workbook name? ie is the active workbook name is NR0000529.xlsm, then the next available name WILL BE NR0000530.xlsm?

If so...
Code:
with ActiveWorkbook
  NewName = left(.name,2) & format(mid(.name, 3,7)+1, "0000000") & right(.name,5)
end with


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I am VBA very basic, I need a code to change file name and maybe be as a question "how many copies required" you enter 10 and it creates 10 copies with next number.

I won't be able to write this macro.

Please help!
 


"How many copies required?"

That does not make sense. You cannot have multiple COPIES of the same file in the same folder and why would you need that?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Yes, Skip

ActiveWorkbook.SaveAs Filename:= _
'" Revenue Streams - Hub Team Site/Private Documents/J NEW RELEASE PROCESS/A. New Release Master List and Entry Form LIVE/NR0000536.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

Thank you
 
They will populate this files every month and all reports will be linked to them. Not my choice.
 
They will populate these files every month and all reports will be linked to them. Not my choice.
 
Skip, does your macro comes on it's own? It des not work for me.
 


Please be clear, concise and complete. Exactly WHAT do your statements mean?

When you say, "It des not work for me," what does than mean?

It gives you a different value than you expect?

It gives you NO value?

It gives you an error?

WHAT?????????

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Nothing Happens when I run your macro!

I recorded macro:

ActiveWorkbook.SaveAs Filename:= _
'" Revenue Streams - Hub Team Site/Private Documents/J NEW RELEASE PROCESS/A. New Release Master List and Entry Form LIVE/NR0000536.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

I need to incorporate file name change from NR0000536 to next number?
 


I did not post a macro.

I posted a code snippet.

Please post the macro you are running.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I don't have macro. That's what I am trying to create the macro which will save exsistant file with a new name.
 

Nothing Happens when I run your macro!
Please post exactly what you ran, that caused, "nothing" to happen!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
ub SaveNext()
'
' SaveNext Macro
'
' Keyboard Shortcut: Ctrl+q
'

With ActiveWorkbook
NewName = Left(.Name, 2) & Format(Mid(.Name, 3, 7) + 1, "0000000") & Right(.Name, 5)
End With

End Sub
 
NewName is a variable. You must USE this variable in some way like this, for instance...
Code:
ub SaveNext()
'
' SaveNext Macro
'
' Keyboard Shortcut: Ctrl+q
'
    
With ActiveWorkbook
  NewName = Left(.Name, 2) & Format(Mid(.Name, 3, 7) + 1, "0000000") & Right(.Name, 5)

  .SaveAs Filename:= _
        '"[URL unfurl="true"]https://internalportal.emihub.com/New[/URL] Revenue Streams - Hub Team Site/Private Documents/J NEW RELEASE PROCESS/A. New Release Master List and Entry Form LIVE/[highlight]" & NewName[/highlight]  _
        , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End With

End Sub
HOWEVER, if I were you, I would TEST the value in NewName, to be certain that the value is what I expect.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top