ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save exact copy of workbook (https://www.excelbanter.com/excel-programming/292084-save-exact-copy-workbook.html)

mike

Save exact copy of workbook
 
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

No Name

Save exact copy of workbook
 
Got it
-----Original Message-----
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
.


Ron de Bruin

Save exact copy of workbook
 
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??



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Mike" wrote in message ...
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





All times are GMT +1. The time now is 08:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com