run-time error '91' - Close Button Error
Sub CloseMacro()
If IntState = "ON" Then CancelDone = False If Application.ActiveWindow.WindowNumber = 1 Then DocIsReadOnly = ActiveWorkbook.ReadOnly StoredId = GetDocumentId() If StoredId < "" Then 'End-Retrieve the open document DocId = StoredId DocWasSaved = ActiveWorkbook.Saved If Not (DocWasSaved) Then ret = GWGetDocInfo(DocId, GW_NAME, DocInfoStr, 255) If ret < GW_OK Or DocInfoStr = "" Then DocInfoStr = DocId End If MsgStr = ClosePromptStr + DocInfoStr + "'?" Style = vbYesNoCancel + vbQuestion ret = MsgBox(MsgStr, Style, "Microsoft Excel") Select Case ret Case vbYes If DocIsReadOnly Then 'create a new profile for the document SaveNewDoc Else ActiveWorkbook.Save End If Case vbNo ActiveWorkbook.Saved = True Case vbCancel CancelDone = True GoTo NeverMind End Select End If Application.ActiveWindow.Close ret = GWCloseDoc(StoredId, 0, 0) NeverMind: Else 'If there is no DocId, check if the document has a name If ActiveWorkbook.Path = "" Or DocIsReadOnly Then 'If the doc is unnamed SaveNewDoc Else 'Just close the Named, Non-profiled document. Application.ActiveWindow.Close End If End If Else 'this is not the first window for the workbook Application.ActiveWindow.Close End If |
All times are GMT +1. The time now is 09:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com