Save exact copy of workbook

M

Mike

When a user opens the workbook I want to rename and save
it as an exact copy including all macros and vba script
except for the rename portion. My initial filename will
be constant (maybe that is obvious) "testabc" so I guess
I could do an if current file name = testabc then do the
filename input box otherwise just continue on.



Private Sub Workbook_Open()
Dim fname As Variant
MsgBox "Blah Blah Blah", vbOKOnly


fname = InputBox("Please Enter file name", "filename")

????????.SaveAs filename:=fname
End Sub
 
R

Ron de Bruin

Try something like this

Private Sub Workbook_Open()
Dim fname As Variant
If ThisWorkbook.Name = "testabc.xls" Then
fname = Application.GetSaveAsFilename("", _
fileFilter:="Excel Files (*.xls), *.xls")
If fname <> False Then
ThisWorkbook.SaveAs Filename:=fname
End If
End If
End Sub

If you cancel the GetSaveAsFilename the file will not be saved???
I don't know if this is importent for you??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top