Sub Fancify()
'Get the file path and file name that you're trying to open
FilenameToOpen = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If FilenameToOpen <> False Then
MsgBox "Open " & FilenameToOpen
Workbooks.Open FilenameToOpen 'open that file
Cells.Select 'select all cells
Selection.Copy 'copy the data
ActiveWindow.Close 'close that file
Range("A1").Select 'go to spot in template you want the top left of the data to be
ActiveSheet.Paste 'paste the data
newFilename = Left(FilenameToOpen, Len(FilenameToOpen) - 4) & "-fancy.xls"
MsgBox (newFilename)
ActiveWorkbook.SaveAs (newFilename) 'prompt them to give a name to this file
ActiveWorkbook.Close 'close
Else
MsgBox "No file selected."
End If
End Sub
>
This will autosave the fancy file as "OldFilename-fancy.xls" in the same directory as the original file. Alternatively, if you want to be able to specify the save name and location each time, change the line "ActiveWorkbook.SaveAs (newFilename)" to "ActiveWorkbook.SaveAs". Or you can mess around with the original filename to choose a different default name / location to save the new file.You are not logged in, either login or create an account to post comments
posted by hellboundforcheddar at 9:28 AM on May 29