Sub SaveAsFoldername()
Dim sFolderName As String
Dim sPath As String
Dim sWBNewName As String
Dim wb As Workbook
'// Get our path, the folder's name thisworkbook resides in, and see what the new //
'// saveas name would be. //
sPath = ThisWorkbook.Path & Application.PathSeparator
sFolderName = Mid(ThisWorkbook.Path, InStrRev(ThisWorkbook.Path, Application.PathSeparator) + 1)
sWBNewName = sFolderName & _
Mid(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, "."))
'// Check to make sure we haven't already done this (ie - make sure the fullname //
'/ doesn't already exist.). //
If Not Len(Dir(sPath & sWBNewName)) > 0 Then
'// SaveCopy, then open it. //
'ThisWorkbook.SaveAs sPath & sWBNewName
ThisWorkbook.SaveCopyAs sPath & sWBNewName
Do
Loop While Len(Dir(sPath & sWBNewName)) = 0
DoEvents
Set wb = Workbooks.Open(sPath & sWBNewName)
DoEvents
'// Original wb gets really depressed... //
With ThisWorkbook
.ChangeFileAccess xlReadOnly
.Saved = True
Kill .FullName
.Close False
End With
End If
End Sub