This code is in a Class Module that's set up to receive events, and it does, but it only see's other workbooks closing and .xla files closing, but never itself (personal.xls).
I've also tried putting a copy in ThisWorkbook, but it doesn't ever fire. Can personal.xls see itself closing?
I currently have it set up like this, but every time I close ANY workbook, it saves personal.xls first. Why does it save personal.xls at all?
Code:
Private Sub Monitor_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
On Error Resume Next
If Wb.Name = "personal.xls" Then
With ThisWorkbook
With .Sheets("Settings")
Dim tbPosition As Integer
tbPosition = Application.CommandBars("RobinsonToolbar").Position
If .Range("ToolbarPosition").Value <> tbPosition Then .Range("ToolbarPosition").Value = tbPosition
End With
.Save
End With
If ThisWorkbook.Saved = False Then ThisWorkbook.Save
End If
End Sub
I've also tried putting a copy in ThisWorkbook, but it doesn't ever fire. Can personal.xls see itself closing?
I currently have it set up like this, but every time I close ANY workbook, it saves personal.xls first. Why does it save personal.xls at all?
Code:
Private Sub Monitor_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
' On Error Resume Next
' If ActiveWorkbook.Name = ThisWorkbook.Name Then
With ThisWorkbook
With .Sheets("Settings")
Dim tbPosition As Integer
tbPosition = Application.CommandBars("RobinsonToolbar").Position
If .Range("ToolbarPosition").Value <> tbPosition Then .Range("ToolbarPosition").Value = tbPosition
End With
'.Save
End With
If ThisWorkbook.Saved = False Then ThisWorkbook.Save
' End If
End Sub