"Save As" Macro
First............you don't need the extra macro to select a cell.
Sub Make_New_Book()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With ActiveSheet
.Range("D1").Select
.Copy
End With
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path _
& "\" & ActiveCell.Value & icounter
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Second.................you didn't see "Assign Macro" because you used a
button from the Control Toolbox, not the Forms Toolbar.
Third....................I don't know how to make the filenames increment
from 1 to 2 to 3 etc.
I'll have to wait for someone with more skills to jump in please.
Gord
On Tue, 12 Aug 2008 17:10:37 -0700, EngelseBoer
wrote:
umm
previous message didnt send...
so here goes again...
Right clicking on the button doesnt give me the option "assign macro"
so i selected "view code " instead and it gave me a new start and end sub
so i merged the other 2 codes into it.
What i run now is the script below -- where ("D1:F2"). are merged and
centered cells containing the new input
and um no -- now it is not creating a "same name 2 -- 3 -- 4" etc file now
though it was creating book 1 2 3 etc befor i recorded a macro to
select those cells 1st, then run your script.
Is it possible to "create same_name 2...3...4" if name already exists ?
though i dont think i will encounter the name being entered 2x in my
application
see new script below
regards
Private Sub CommandButton1_Click()
'
' Macro3 Macro
' Macro recorded 12/08/2008 by Malcolm
'
'
Range("D1:F2").Select
Application.Run "Book1.xls!Make_New_Book"
End Sub
Sub Make_New_Book()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path _
& "\" & ActiveCell.Value
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
"Gord Dibben" wrote:
The code I provided will not create "same file name 2", then 3 etc.
Application.DisplayAlerts = False will cause an overwrite with no warning.
You must have altered the code.
Gord
On Tue, 12 Aug 2008 16:22:00 -0700, EngelseBoer
wrote:
simply creates a ne file with the new name
if that name already exists it creates a "same file name 2" then 3 etc
|