Save a Workbood with a Unique Name

Home           Programming       Favorites      

This function will return true after it successfully saves a workbook with a unique name.

Function WorkbookNewNameSaveAs() As Boolean
   On Error GoTo errHandler1
   WorkbookNewNameSaveAs = False

   Set objWorkBook = objExcel.Workbooks.Add
   strNewName = GetNewWorkbookName
   Set objWorksheet = objWorkBook.ActiveSheet

   objWorkBook.SaveAs (strNewName)
   WorkbookNewNameSaveAs = True
   Exit Function
   WorkbookNewNameSaveAs = False
   MsgBox "WorkbookNewNameSaveAs has failed", _
   vbCritical, "Function Failure"

End Function