SaveAs MaCRO


Posted by Max Maxwell on February 03, 2002 11:13 AM

Problem: I need to have a macro that asks for a filename to SAVEAS and THEN saves it under that name and then reloads original file. Is this possible?



Posted by Jacob on February 03, 2002 5:01 PM

Hi

This code will save the file as a name you specify in the same path then close the new workbook.

Sub SaveIt()

Dim MyPath As String
Dim MyName As String
Dim SaveAsName As String

MyPath = ThisWorkbook.Path
MyName = ThisWorkbook.Name
SaveAsName = InputBox("What name do you want to save this as?")

ActiveWorkbook.SaveAs Filename:=MyPath & "\" & SaveAsName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
SaveAsName = ActiveWorkbook.Name

Workbooks.Open Filename:=MyPath & "\" & MyName

Windows(SaveAsName).Close

End Sub


HTH

Jacob