J
JNW
I have a macro that logs out all users (except myself). It restores the
user's originals settings when closing. It also closes the workbook if more
than workbook are open, and closes Excel if this is the only workbook open.
It opens as a read-only as it is just the interface for the user and all
other items that are saved are not located in this workbook.
I want to close without the save dialog box appearing, and I've tried a few
things already (checked previous posts without success) but to no avail. Any
help is appreciated. All relevant code should be below.
Sub LogoutAllElse()
Dim Sh As Worksheet
Dim Row As Long
Dim TBar As String
Dim Msg As String
'Resets toolbars to the user's original settings
Row = 1
TBar = Workbooks("I.P.C. (1.0).xls").Sheets("File info").Cells(Row, 1)
Do While TBar <> ""
Application.CommandBars(TBar).Visible = True
Row = Row + 1
TBar = Workbooks("I.P.C. (1.0).xls").Sheets("File info").Cells(Row, 1)
Loop
Application.DisplayFormulaBar = True
Application.DisplayStatusBar = True
Application.DisplayScrollBars = True
'Counts open workbooks
Dim i As Integer
Dim wkb As Workbook
For Each wkb In Application.Workbooks
If wkb.Name <> "PERSONAL.XLS" Then
i = i + 1
End If
Next wkb
'Closes workbook if more than one open
'Closes Excel if just thisworkbook open
If i > 1 Then
Application.DisplayAlerts = False
ThisWorkbook.Close False
Application.DisplayAlerts = True
Else
Application.DisplayAlerts = False
ThisWorkbook.Saved = True
Application.Quit
Application.DisplayAlerts = True
End If
End Sub
user's originals settings when closing. It also closes the workbook if more
than workbook are open, and closes Excel if this is the only workbook open.
It opens as a read-only as it is just the interface for the user and all
other items that are saved are not located in this workbook.
I want to close without the save dialog box appearing, and I've tried a few
things already (checked previous posts without success) but to no avail. Any
help is appreciated. All relevant code should be below.
Sub LogoutAllElse()
Dim Sh As Worksheet
Dim Row As Long
Dim TBar As String
Dim Msg As String
'Resets toolbars to the user's original settings
Row = 1
TBar = Workbooks("I.P.C. (1.0).xls").Sheets("File info").Cells(Row, 1)
Do While TBar <> ""
Application.CommandBars(TBar).Visible = True
Row = Row + 1
TBar = Workbooks("I.P.C. (1.0).xls").Sheets("File info").Cells(Row, 1)
Loop
Application.DisplayFormulaBar = True
Application.DisplayStatusBar = True
Application.DisplayScrollBars = True
'Counts open workbooks
Dim i As Integer
Dim wkb As Workbook
For Each wkb In Application.Workbooks
If wkb.Name <> "PERSONAL.XLS" Then
i = i + 1
End If
Next wkb
'Closes workbook if more than one open
'Closes Excel if just thisworkbook open
If i > 1 Then
Application.DisplayAlerts = False
ThisWorkbook.Close False
Application.DisplayAlerts = True
Else
Application.DisplayAlerts = False
ThisWorkbook.Saved = True
Application.Quit
Application.DisplayAlerts = True
End If
End Sub